This is an automated email from the ASF dual-hosted git repository.
gopidesu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new fae7590e12e Add --warn-unreachable flag to mypy as a optional flag
(#53398)
fae7590e12e is described below
commit fae7590e12e11c97d4737badf560bdc22908464f
Author: GPK <[email protected]>
AuthorDate: Wed Jul 16 18:24:07 2025 +0100
Add --warn-unreachable flag to mypy as a optional flag (#53398)
---
scripts/ci/pre_commit/mypy_folder.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/scripts/ci/pre_commit/mypy_folder.py
b/scripts/ci/pre_commit/mypy_folder.py
index dc26cd7fc06..3faaea223d6 100755
--- a/scripts/ci/pre_commit/mypy_folder.py
+++ b/scripts/ci/pre_commit/mypy_folder.py
@@ -54,6 +54,7 @@ if len(sys.argv) < 2:
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:
@@ -127,14 +128,21 @@ else:
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]