This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-0-test by this push:
     new bafddb8dde8 [v3-0-test] Update mypy script with --warn-unused-ignores 
(#53240) (#53245)
bafddb8dde8 is described below

commit bafddb8dde8aa46a1507f664fdf69f02c69871b1
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Jul 12 20:51:31 2025 +0200

    [v3-0-test] Update mypy script with --warn-unused-ignores (#53240) (#53245)
    
    * Update mypy script with --warn-unused-ignores
    
    * Add doc information
    (cherry picked from commit 1d7e0aed6ca9f2603d1e9e8d3de2d9b8759d6823)
    
    Co-authored-by: GPK <[email protected]>
---
 contributing-docs/08_static_code_checks.rst |  6 ++++++
 scripts/ci/pre_commit/mypy_folder.py        | 11 +++++++++++
 2 files changed, 17 insertions(+)

diff --git a/contributing-docs/08_static_code_checks.rst 
b/contributing-docs/08_static_code_checks.rst
index ab4ec43edec..b8144881544 100644
--- a/contributing-docs/08_static_code_checks.rst
+++ b/contributing-docs/08_static_code_checks.rst
@@ -508,6 +508,12 @@ For example:
 
   pre-commit run --hook-stage manual mypy-airflow --all-files
 
+To show unused mypy ignores for any providers/airflow etc, eg: run below 
command:
+
+.. code-block:: bash
+  export SHOW_UNUSED_MYPY_WARNINGS=true
+  pre-commit run --hook-stage manual mypy-airflow --all-files
+
 MyPy uses a separate docker-volume (called ``mypy-cache-volume``) that keeps 
the cache of last MyPy
 execution in order to speed MyPy checks up (sometimes by order of magnitude). 
While in most cases MyPy
 will handle refreshing the cache when and if needed, there are some cases when 
it won't (cache invalidation
diff --git a/scripts/ci/pre_commit/mypy_folder.py 
b/scripts/ci/pre_commit/mypy_folder.py
index d3ca454e385..87704282fc4 100755
--- a/scripts/ci/pre_commit/mypy_folder.py
+++ b/scripts/ci/pre_commit/mypy_folder.py
@@ -53,6 +53,8 @@ if len(sys.argv) < 2:
 
 mypy_folders = sys.argv[1:]
 
+show_unused_warnings = os.environ.get("SHOW_UNUSED_MYPY_WARNINGS", "false")
+
 for mypy_folder in mypy_folders:
     if mypy_folder not in ALLOWED_FOLDERS:
         console.print(
@@ -125,6 +127,15 @@ else:
 
 print(f"Running mypy with {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 = f"TERM=ansi mypy {shlex.quote(FILE_ARGUMENT)} 
--warn-unused-ignores"
+else:
+    mypy_cmd = f"TERM=ansi mypy {shlex.quote(FILE_ARGUMENT)}"
+
 cmd = ["bash", "-c", f"TERM=ansi mypy {shlex.quote(FILE_ARGUMENT)}"]
 
 res = run_command_via_breeze_shell(

Reply via email to