Skip to content

Commit

Permalink
Remove an unnecessary cast to Any (#14816)
Browse files Browse the repository at this point in the history
Typeshed has a more accurate annotation for this attribute these days
  • Loading branch information
AlexWaygood authored Mar 1, 2023
1 parent a618110 commit dc5ff29
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions mypyc/test/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import subprocess
import sys
import time
from typing import Any, Iterator, cast
from typing import Any, Iterator

from mypy import build
from mypy.errors import CompileError
Expand Down Expand Up @@ -108,15 +108,13 @@ def run_setup(script_name: str, script_args: list[str]) -> bool:
finally:
sys.argv = save_argv
except SystemExit as e:
# typeshed reports code as being an int but that is wrong
code = cast(Any, e).code
# distutils converts KeyboardInterrupt into a SystemExit with
# "interrupted" as the argument. Convert it back so that
# pytest will exit instead of just failing the test.
if code == "interrupted":
if e.code == "interrupted":
raise KeyboardInterrupt from e

return code == 0 or code is None
return e.code == 0 or e.code is None

return True

Expand Down

0 comments on commit dc5ff29

Please sign in to comment.