Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eb51277

Browse filesBrowse 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
Copy full SHA for eb51277

File tree

2 files changed

+5
-6
lines changed
Filter options

2 files changed

+5
-6
lines changed

‎git/util.py

Copy file name to clipboardExpand all lines: git/util.py
+2-3Lines 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

Copy file name to clipboardExpand all lines: test/test_util.py
+3-3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.