Skip to content

Commit 7204c13

Browse files
committed
Fix new mypy error in _read_win_env_flag
As noted in 88557bc before this, that change added a couple of new mypy errors about unreachable code, where it is intentionally unreachable because it is for one platform and not another. This fixes one of them, though a fix that incorporates more of what can now be statically known about the return value based on the platform may be preferable.
1 parent 88557bc commit 7204c13

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

Diff for: git/util.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,12 @@
107107
_logger = logging.getLogger(__name__)
108108

109109

110-
def _read_win_env_flag(name: str, default: bool) -> bool:
111-
"""Read a boolean flag from an environment variable on Windows.
110+
def _read_env_flag(name: str, default: bool) -> bool:
111+
"""Read a boolean flag from an environment variable.
112112
113113
:return:
114-
On Windows, the flag, or the `default` value if absent or ambiguous.
115-
On all other operating systems, ``False``.
116-
117-
:note:
118-
This only accesses the environment on Windows.
114+
The flag, or the `default` value if absent or ambiguous.
119115
"""
120-
if sys.platform != "win32":
121-
return False
122-
123116
try:
124117
value = os.environ[name]
125118
except KeyError:
@@ -140,6 +133,19 @@ def _read_win_env_flag(name: str, default: bool) -> bool:
140133
return default
141134

142135

136+
def _read_win_env_flag(name: str, default: bool) -> bool:
137+
"""Read a boolean flag from an environment variable on Windows.
138+
139+
:return:
140+
On Windows, the flag, or the `default` value if absent or ambiguous.
141+
On all other operating systems, ``False``.
142+
143+
:note:
144+
This only accesses the environment on Windows.
145+
"""
146+
return sys.platform == "win32" and _read_env_flag(name, default)
147+
148+
143149
#: We need an easy way to see if Appveyor TCs start failing,
144150
#: so the errors marked with this var are considered "acknowledged" ones, awaiting remedy,
145151
#: till then, we wish to hide them.

0 commit comments

Comments
 (0)