Skip to content

Commit

Permalink
Suppress type errors in restore_use_shell_state _USE_SHELL branches
Browse files Browse the repository at this point in the history
These conditional branches are kept so alternative implementations
can be examined, including if they need to be investigated to
satisfy some future requirement. But to be unittest.mock.patch
patchable, the approaches that would have a _USE_SHELL backing
attribute would be difficult to implement in a straightforward way,
which seems not to be needed or justified at this time.

Since that is not anticipated (except as an intermediate step in
development), these suppressions make sense, and they will also be
reported by mypy if the implementation changes to benefit from them
(so long as it is configured with warn_unused_ignores set to true).
  • Loading branch information
EliahKagan committed Mar 29, 2024
1 parent 4037108 commit 0e311bf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/deprecation/test_cmd_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def restore_use_shell_state() -> Generator[None, None, None]:

# Try to save the original private state.
try:
old_private_value = Git._USE_SHELL
old_private_value = Git._USE_SHELL # type: ignore[attr-defined]
except AttributeError:
separate_backing_attribute = False
try:
Expand Down Expand Up @@ -139,7 +139,7 @@ def restore_use_shell_state() -> Generator[None, None, None]:
finally:
# Try to restore the original private state.
if separate_backing_attribute:
Git._USE_SHELL = old_private_value
Git._USE_SHELL = old_private_value # type: ignore[attr-defined]
elif old_private_value is not no_value:
type.__setattr__(Git, "USE_SHELL", old_private_value)

Expand Down

0 comments on commit 0e311bf

Please sign in to comment.