Skip to content

Remove unused type: ignore comments in airflow-core - #75078

Merged
vincbeck merged 2 commits into
apache:mainfrom
HsuehYi:remove-unused-mypy-ignores
Oct 19, 2026
Merged

vincbeck merged 2 commits into
apache:mainfrom
HsuehYi:remove-unused-mypy-ignores

Conversation

@HsuehYi

@HsuehYi HsuehYi commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

mypy --warn-unused-ignores — exposed to contributors as
SHOW_UNUSED_MYPY_WARNINGS=true prek run mypy-airflow-core --all-files
(see contributing-docs/08_static_code_checks.rst) — reports stale # type: ignore
comments in airflow-core: 60 comments that suppress nothing at all, and 3 that
list an unused error code next to a live one. Stale suppressions make it hard to
tell which ignores are still load-bearing, so this PR drops the dead comments and
narrows the remaining brackets to the codes they actually need.

Changes (28 files, all in airflow-core):

  • removed 60 whole-comment # type: ignore suppressions (src + tests);
  • narrowed 3 brackets:
    • src/airflow/timetables/simple.py:47: [misc,no-redef] → [no-redef]
    • tests/unit/plugins/test_plugins_manager.py:278/279: [list-item, typeddict-item] → [typeddict-item]
  • src/airflow/api_fastapi/core_api/routes/public/extra_links.py: with the trailing
    comment gone, ruff format keeps the generator expression on one line.
  • kept the [return] ignore in src/airflow/utils/memray_utils.py: it is only reported
    unused when the optional memray extra is not installed; with memray present, as in
    CI, Tracker.__exit__ may suppress exceptions, so mypy needs it. A comment now
    explains this.

Verification (run locally):

  • prek run mypy-airflow-core --all-files → passed
  • mypy --warn-unused-ignores with the memray extra installed (matches CI) → passed
    (no unused ignores remain)
  • breeze run --python 3.11 … mypy (same invocation as the CI static-check job) → passed
  • commit and pre-push hook suites → passed (the Docker-backed generate-openapi-spec
    ran successfully once Docker was available)

No runtime behaviour changes; no tests were run beyond the checks above.


Was generative AI tooling used to co-author this PR?
  • Yes — OpenCode (DeepSeek V4.1 Flash Free)

Generated-by: OpenCode (DeepSeek V4.1 Flash Free) following the guidelines

mypy --warn-unused-ignores (exposed locally as SHOW_UNUSED_MYPY_WARNINGS=true)
flags stale `# type: ignore` comments: 61 that suppress nothing at all and 3
whose bracket lists an error code next to a live one. Stale suppressions make
it hard to tell which ignores are still load-bearing, so drop the dead ones
and keep the remaining brackets limited to the codes they actually need.

@hussein-awala hussein-awala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if the CI is green

@Lee-W Lee-W left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean up. Let's see how CI says 🚀

`mypy --warn-unused-ignores` only reports the `[return]` ignore in
memray_utils.py as unused when the optional memray extra is not installed
(the dedicated local mypy venv does not install it). With memray installed,
as in the CI image, `Tracker.__exit__` may suppress exceptions, so mypy
cannot prove that every path returns. Restore the ignore and add a comment
so that a future cleanup does not drop it again.
@HsuehYi
HsuehYi force-pushed the remove-unused-mypy-ignores branch from d28882a to 2977a75 Compare October 19, 2026 11:42
@vincbeck
vincbeck merged commit fa83bd0 into apache:main Oct 19, 2026
72 checks passed
potiuk added a commit that referenced this pull request Oct 19, 2026
#75078 dropped the type: ignores in this expression, which only held
while mypy did not check the body; typing cls as type[Backfill] keeps it
clean on SQLAlchemy 2.0 and 2.1, as dag_display_name and
DagRun.duration already are. Also annotate the Anthropic stream fixture
so mypy can index its events.

Generated-by: Claude Opus 5
Lee-W added a commit that referenced this pull request Oct 20, 2026
* [main] CI: Upgrade important CI environment

* Fix "prek run update-providers-build-files --all-files"

* Fix CI breakages from the dependency upgrade

- snowflake: snowflake-sqlalchemy (up to 1.11.1) cannot be imported on
  SQLAlchemy 2.1, which made ORMSelectCompileState private. Cap
  sqlalchemy<2.1 in the provider; the workspace lock resolves back to
  SQLAlchemy 2.0.54. Removing the cap is tracked in #75118.
- airflow-core: type the dag_display_name and duration hybrid expressions
  against the class (type[...] -> ColumnElement) and fix _get_dialect's
  return type, so mypy holds on SQLAlchemy 2.0 and 2.1.
- common.ai: declare the OpenAI Decisions and System One vendors added in
  pydantic-ai 2.53/2.55; reject sqlglot >= 30.22's exp.ListStage
  (Snowflake LIST/LS @stage) on the allow_writes path; adapt tests to
  pydantic-ai's streamed Anthropic requests and new request counting, and
  to sqlglot's MySQL "--+" tokenization.

Generated-by: Claude Opus 5

* Type Backfill.duration expression against the class

#75078 dropped the type: ignores in this expression, which only held
while mypy did not check the body; typing cls as type[Backfill] keeps it
clean on SQLAlchemy 2.0 and 2.1, as dag_display_name and
DagRun.duration already are. Also annotate the Anthropic stream fixture
so mypy can index its events.

Generated-by: Claude Opus 5

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Wei Lee <[email protected]>
Co-authored-by: Jarek Potiuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants