Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions contributing-docs/08_static_code_checks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions scripts/ci/pre_commit/mypy_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@

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(
Expand Down Expand Up @@ -125,6 +127,15 @@ def get_all_files(folder: str) -> list[str]:

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(
Expand Down