Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions scripts/ci/pre_commit/mypy_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
mypy_folders = sys.argv[1:]

show_unused_warnings = os.environ.get("SHOW_UNUSED_MYPY_WARNINGS", "false")
show_unreachable_warnings = os.environ.get("SHOW_UNREACHABLE_MYPY_WARNINGS", "false")

for mypy_folder in mypy_folders:
if mypy_folder not in ALLOWED_FOLDERS:
Expand Down Expand Up @@ -127,14 +128,21 @@ def get_all_files(folder: str) -> list[str]:

print(f"Running mypy with {FILE_ARGUMENT}")

mypy_cmd_parts = [f"TERM=ansi mypy {shlex.quote(FILE_ARGUMENT)}"]

if show_unused_warnings == "true":
console.print(
"[info]Running mypy with --warn-unused-ignores to display unused ignores, unset environment variable: SHOW_UNUSED_MYPY_WARNINGS to runoff this behaviour"
)
mypy_cmd_parts.append("--warn-unused-ignores")

mypy_cmd = f"TERM=ansi mypy {shlex.quote(FILE_ARGUMENT)} --warn-unused-ignores"
else:
mypy_cmd = f"TERM=ansi mypy {shlex.quote(FILE_ARGUMENT)}"
if show_unreachable_warnings == "true":
console.print(
"[info]Running mypy with --warn-unreachable to display unreachable code, unset environment variable: SHOW_UNREACHABLE_MYPY_WARNINGS to runoff this behaviour"
)
mypy_cmd_parts.append("--warn-unreachable")

mypy_cmd = " ".join(mypy_cmd_parts)

cmd = ["bash", "-c", mypy_cmd]

Expand Down