4
4
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
5
5
6
6
import contextlib
7
+ from dataclasses import dataclass
7
8
from io import BytesIO
8
9
import logging
9
10
import os
17
18
18
19
import ddt
19
20
import pytest
20
- from sumtypes import constructor , sumtype
21
21
22
22
from git import (
23
23
BlobFilter ,
@@ -66,34 +66,48 @@ def _get_windows_ansi_encoding():
66
66
return f"cp{ value } "
67
67
68
68
69
- @sumtype
70
69
class WinBashStatus :
71
- """Status of bash.exe for native Windows . Affects which commit hook tests can pass.
70
+ """Namespace of native-Windows bash.exe statuses . Affects what hook tests can pass.
72
71
73
72
Call check() to check the status. (CheckError and WinError should not typically be
74
73
used to trigger skip or xfail, because they represent unexpected situations.)
75
74
"""
76
75
77
- Inapplicable = constructor ()
78
- """This system is not native Windows: either not Windows at all, or Cygwin."""
76
+ @dataclass
77
+ class Inapplicable :
78
+ """This system is not native Windows: either not Windows at all, or Cygwin."""
79
79
80
- Absent = constructor ()
81
- """No command for bash.exe is found on the system."""
80
+ @dataclass
81
+ class Absent :
82
+ """No command for bash.exe is found on the system."""
82
83
83
- Native = constructor ()
84
- """Running bash.exe operates outside any WSL distribution (as with Git Bash)."""
84
+ @dataclass
85
+ class Native :
86
+ """Running bash.exe operates outside any WSL distribution (as with Git Bash)."""
85
87
86
- Wsl = constructor ()
87
- """Running bash.exe calls bash in a WSL distribution."""
88
+ @dataclass
89
+ class Wsl :
90
+ """Running bash.exe calls bash in a WSL distribution."""
88
91
89
- WslNoDistro = constructor ("process" , "message" )
90
- """Running bash.exe tries to run bash on a WSL distribution, but none exists."""
92
+ @dataclass
93
+ class WslNoDistro :
94
+ """Running bash.exe tries to run bash on a WSL distribution, but none exists."""
91
95
92
- CheckError = constructor ( " process" , "message" )
93
- """Running bash.exe fails in an unexpected error or gives unexpected output."""
96
+ process : "subprocess.CompletedProcess[bytes]"
97
+ message : str
94
98
95
- WinError = constructor ("exception" )
96
- """bash.exe may exist but can't run. CreateProcessW fails unexpectedly."""
99
+ @dataclass
100
+ class CheckError :
101
+ """Running bash.exe fails in an unexpected error or gives unexpected output."""
102
+
103
+ process : "subprocess.CompletedProcess[bytes]"
104
+ message : str
105
+
106
+ @dataclass
107
+ class WinError :
108
+ """bash.exe may exist but can't run. CreateProcessW fails unexpectedly."""
109
+
110
+ exception : OSError
97
111
98
112
@classmethod
99
113
def check (cls ):
0 commit comments