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
except KeyError:
@@ -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-
return value
125+
return bool(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
return ast.literal_eval(output)
522522

523-
assert_true_iff_win = self.assertTrue if os.name == "nt" else self.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
for msg, env_var_value in truthy_cases:
544544
with self.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
for msg, env_var_value in falsy_cases:
548548
with self.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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy