Skip to content

Commit eb51277

Browse files
committed
Make HIDE_* attributes always bool
For now, this doesn't change how the correspondng environment variables are interpreted, in terms of truth and falsehood. But it does *convert* them to bool, so that the values of the HIDE_WINDOWS_KNOWN_ERRORS and HIDE_WINDOWS_FREEZE_ERRORS attributes are always bools. It also updates the tests accordingly, to validate this behavior.
1 parent 7604da1 commit eb51277

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

‎git/util.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
log=logging.getLogger(__name__)
111111

112112

113-
def_read_env_flag(name: str, default: bool) ->Union[bool, str]:
113+
def_read_env_flag(name: str, default: bool) ->bool:
114114
try:
115115
value=os.environ[name]
116116
exceptKeyError:
@@ -121,9 +121,8 @@ def _read_env_flag(name: str, default: bool) -> Union[bool, str]:
121121
name,
122122
)
123123

124-
# FIXME: This should always return bool, as that is how it is used.
125124
# FIXME: This should treat some values besides "" as expressing falsehood.
126-
returnvalue
125+
returnbool(value)
127126

128127

129128
#: We need an easy way to see if Appveyor TCs start failing,

‎test/test_util.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def run_parse(value):
520520
)
521521
returnast.literal_eval(output)
522522

523-
assert_true_iff_win=self.assertTrueifos.name=="nt"elseself.assertFalse
523+
true_iff_win=os.name=="nt"# Same as is_win, but don't depend on that here.
524524

525525
truthy_cases= [
526526
("unset", None),
@@ -542,8 +542,8 @@ def run_parse(value):
542542

543543
formsg, env_var_valueintruthy_cases:
544544
withself.subTest(msg, env_var_value=env_var_value):
545-
assert_true_iff_win(run_parse(env_var_value))
545+
self.assertIs(run_parse(env_var_value), true_iff_win)
546546

547547
formsg, env_var_valueinfalsy_cases:
548548
withself.subTest(msg, env_var_value=env_var_value):
549-
self.assertFalse(run_parse(env_var_value))
549+
self.assertIs(run_parse(env_var_value), False)

0 commit comments

Comments
(0)