This is an automated email from the ASF dual-hosted git repository.
vincbeck 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 fa83bd029cb Remove unused type: ignore comments in airflow-core
(#75078)
fa83bd029cb is described below
commit fa83bd029cb9ad9833e20d5f89caa5cdc4b8128a
Author: CA <[email protected]>
AuthorDate: Mon Oct 19 22:43:36 2026 +0800
Remove unused type: ignore comments in airflow-core (#75078)
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.
---
airflow-core/src/airflow/api_fastapi/compat.py | 2 +-
.../api_fastapi/core_api/routes/public/dag_run.py | 14 +++++++-------
.../core_api/routes/public/extra_links.py | 5 +----
.../core_api/routes/public/task_instances.py | 20 ++++++++++----------
.../api_fastapi/execution_api/routes/__init__.py | 2 +-
.../execution_api/versions/v2025_08_10.py | 2 +-
.../execution_api/versions/v2025_10_27.py | 2 +-
.../execution_api/versions/v2025_11_05.py | 2 +-
.../execution_api/versions/v2026_04_06.py | 16 ++++++++--------
.../execution_api/versions/v2026_06_30.py | 14 +++++++-------
.../execution_api/versions/v2026_10_30.py | 6 +++---
.../src/airflow/jobs/triggerer_job_runner.py | 2 +-
airflow-core/src/airflow/models/backfill.py | 4 ++--
airflow-core/src/airflow/models/serialized_dag.py | 4 ++--
airflow-core/src/airflow/models/taskinstance.py | 2 +-
.../serialization/definitions/mappedoperator.py | 2 +-
airflow-core/src/airflow/timetables/simple.py | 2 +-
airflow-core/src/airflow/utils/cli_action_loggers.py | 2 +-
airflow-core/src/airflow/utils/db_cleanup.py | 2 +-
airflow-core/src/airflow/utils/memray_utils.py | 2 ++
airflow-core/src/airflow/utils/retries.py | 2 +-
.../tests/unit/cli/commands/test_dag_command.py | 2 +-
.../tests/unit/executors/test_base_executor.py | 6 +++---
airflow-core/tests/unit/executors/test_workloads.py | 4 ++--
.../tests/unit/migrations/test_migration_patterns.py | 2 +-
.../tests/unit/models/test_connection_test.py | 2 +-
.../tests/unit/plugins/test_plugins_manager.py | 4 ++--
airflow-core/tests/unit/utils/test_db_manager.py | 2 +-
28 files changed, 65 insertions(+), 66 deletions(-)
diff --git a/airflow-core/src/airflow/api_fastapi/compat.py
b/airflow-core/src/airflow/api_fastapi/compat.py
index 75e2e79d637..683677bc7a3 100644
--- a/airflow-core/src/airflow/api_fastapi/compat.py
+++ b/airflow-core/src/airflow/api_fastapi/compat.py
@@ -31,6 +31,6 @@ from fastapi import status
try:
HTTP_422_UNPROCESSABLE_CONTENT = status.HTTP_422_UNPROCESSABLE_CONTENT
except AttributeError:
- HTTP_422_UNPROCESSABLE_CONTENT = status.HTTP_422_UNPROCESSABLE_ENTITY #
type: ignore[attr-defined]
+ HTTP_422_UNPROCESSABLE_CONTENT = status.HTTP_422_UNPROCESSABLE_ENTITY
__all__ = ["HTTP_422_UNPROCESSABLE_CONTENT"]
diff --git
a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dag_run.py
b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dag_run.py
index 974f086a059..68fd621cd3a 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dag_run.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/dag_run.py
@@ -956,7 +956,7 @@ def get_list_dag_runs_batch(
session: SessionDep,
) -> DAGRunCollectionResponse:
"""Get a list of Dag Runs."""
- dag_ids = FilterParam(DagRun.dag_id, body.dag_ids, FilterOptionEnum.IN) #
type: ignore[arg-type]
+ dag_ids = FilterParam(DagRun.dag_id, body.dag_ids, FilterOptionEnum.IN)
logical_date = RangeFilter(
Range(
lower_bound_gte=body.logical_date_gte,
@@ -964,7 +964,7 @@ def get_list_dag_runs_batch(
upper_bound_lte=body.logical_date_lte,
upper_bound_lt=body.logical_date_lt,
),
- attribute=DagRun.logical_date, # type: ignore[arg-type]
+ attribute=DagRun.logical_date,
)
run_after = RangeFilter(
Range(
@@ -973,7 +973,7 @@ def get_list_dag_runs_batch(
upper_bound_lte=body.run_after_lte,
upper_bound_lt=body.run_after_lt,
),
- attribute=DagRun.run_after, # type: ignore[arg-type]
+ attribute=DagRun.run_after,
)
start_date = RangeFilter(
Range(
@@ -982,7 +982,7 @@ def get_list_dag_runs_batch(
upper_bound_lte=body.start_date_lte,
upper_bound_lt=body.start_date_lt,
),
- attribute=DagRun.start_date, # type: ignore[arg-type]
+ attribute=DagRun.start_date,
)
end_date = RangeFilter(
Range(
@@ -991,7 +991,7 @@ def get_list_dag_runs_batch(
upper_bound_lte=body.end_date_lte,
upper_bound_lt=body.end_date_lt,
),
- attribute=DagRun.end_date, # type: ignore[arg-type]
+ attribute=DagRun.end_date,
)
duration = RangeFilter(
Range(
@@ -1002,8 +1002,8 @@ def get_list_dag_runs_batch(
),
attribute=DagRun.duration, # type: ignore[arg-type]
)
- conf_contains = FilterParam(DagRun.conf, body.conf_contains,
FilterOptionEnum.CONTAINS) # type: ignore[arg-type]
- state = FilterParam(DagRun.state, body.states, FilterOptionEnum.ANY_EQUAL)
# type: ignore[arg-type]
+ conf_contains = FilterParam(DagRun.conf, body.conf_contains,
FilterOptionEnum.CONTAINS)
+ state = FilterParam(DagRun.state, body.states, FilterOptionEnum.ANY_EQUAL)
offset = OffsetFilter(body.page_offset)
limit = LimitFilter(body.page_limit)
diff --git
a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/extra_links.py
b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/extra_links.py
index f568c24ca0e..0a3c8970538 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/extra_links.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/extra_links.py
@@ -120,10 +120,7 @@ def get_extra_links(
)
]
- all_extra_link_pairs = (
- (link_name, task.get_extra_links(ti, link_name))
- for link_name in link_names # type: ignore[arg-type]
- )
+ all_extra_link_pairs = ((link_name, task.get_extra_links(ti, link_name))
for link_name in link_names)
all_extra_links = {link_name: link_url or None for link_name, link_url in
sorted(all_extra_link_pairs)}
return ExtraLinkCollectionResponse(
diff --git
a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py
b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py
index ba7290eb707..1fe5224a0d3 100644
---
a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py
+++
b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py
@@ -846,9 +846,9 @@ def get_task_instances_batch(
resolver: CoordinateResolverDep,
) -> TaskInstanceCollectionResponse:
"""Get list of task instances."""
- dag_ids = FilterParam(TI.dag_id, body.dag_ids, FilterOptionEnum.IN) #
type: ignore[arg-type]
- dag_run_ids = FilterParam(TI.run_id, body.dag_run_ids,
FilterOptionEnum.IN) # type: ignore[arg-type]
- task_ids = FilterParam(TI.task_id, body.task_ids, FilterOptionEnum.IN) #
type: ignore[arg-type]
+ dag_ids = FilterParam(TI.dag_id, body.dag_ids, FilterOptionEnum.IN)
+ dag_run_ids = FilterParam(TI.run_id, body.dag_run_ids, FilterOptionEnum.IN)
+ task_ids = FilterParam(TI.task_id, body.task_ids, FilterOptionEnum.IN)
run_after = RangeFilter(
Range(
lower_bound_gte=body.run_after_gte,
@@ -874,7 +874,7 @@ def get_task_instances_batch(
upper_bound_lte=body.start_date_lte,
upper_bound_lt=body.start_date_lt,
),
- attribute=TI.start_date, # type: ignore[arg-type]
+ attribute=TI.start_date,
)
end_date = RangeFilter(
Range(
@@ -883,7 +883,7 @@ def get_task_instances_batch(
upper_bound_lte=body.end_date_lte,
upper_bound_lt=body.end_date_lt,
),
- attribute=TI.end_date, # type: ignore[arg-type]
+ attribute=TI.end_date,
)
duration = RangeFilter(
Range(
@@ -892,12 +892,12 @@ def get_task_instances_batch(
upper_bound_lte=body.duration_lte,
upper_bound_lt=body.duration_lt,
),
- attribute=TI.duration, # type: ignore[arg-type]
+ attribute=TI.duration,
)
- state = FilterParam(TI.state, body.state, FilterOptionEnum.ANY_EQUAL) #
type: ignore[arg-type]
- pool = FilterParam(TI.pool, body.pool, FilterOptionEnum.ANY_EQUAL) #
type: ignore[arg-type]
- queue = FilterParam(TI.queue, body.queue, FilterOptionEnum.ANY_EQUAL) #
type: ignore[arg-type]
- executor = FilterParam(TI.executor, body.executor,
FilterOptionEnum.ANY_EQUAL) # type: ignore[arg-type]
+ state = FilterParam(TI.state, body.state, FilterOptionEnum.ANY_EQUAL)
+ pool = FilterParam(TI.pool, body.pool, FilterOptionEnum.ANY_EQUAL)
+ queue = FilterParam(TI.queue, body.queue, FilterOptionEnum.ANY_EQUAL)
+ executor = FilterParam(TI.executor, body.executor,
FilterOptionEnum.ANY_EQUAL)
offset = OffsetFilter(body.page_offset)
limit = LimitFilter(body.page_limit)
diff --git
a/airflow-core/src/airflow/api_fastapi/execution_api/routes/__init__.py
b/airflow-core/src/airflow/api_fastapi/execution_api/routes/__init__.py
index 4653945ef42..7ecc398a23e 100644
--- a/airflow-core/src/airflow/api_fastapi/execution_api/routes/__init__.py
+++ b/airflow-core/src/airflow/api_fastapi/execution_api/routes/__init__.py
@@ -47,7 +47,7 @@ execution_api_router = APIRouter()
execution_api_router.include_router(health.router, tags=["Health"])
# _Every_ single endpoint under here must be authenticated. Some do further
checks on top of these
-authenticated_router =
VersionedAPIRouter(dependencies=[Security(require_auth)]) # type:
ignore[list-item]
+authenticated_router =
VersionedAPIRouter(dependencies=[Security(require_auth)])
authenticated_router.include_router(assets.router, prefix="/assets",
tags=["Assets"])
authenticated_router.include_router(asset_events.router,
prefix="/asset-events", tags=["Asset Events"])
diff --git
a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_08_10.py
b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_08_10.py
index ccac0b94542..9107987d022 100644
--- a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_08_10.py
+++ b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_08_10.py
@@ -34,7 +34,7 @@ class AddDagRunStateFieldAndPreviousEndpoint(VersionChange):
)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def remove_state_from_dag_run(response: ResponseInfo) -> None: # type:
ignore[misc]
+ def remove_state_from_dag_run(response: ResponseInfo) -> None:
"""Remove the `state` field from the dag_run object when converting to
the previous version."""
if "dag_run" in response.body and isinstance(response.body["dag_run"],
dict):
response.body["dag_run"].pop("state", None)
diff --git
a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_10_27.py
b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_10_27.py
index b16f00519bb..a9131b9ffb8 100644
--- a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_10_27.py
+++ b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_10_27.py
@@ -30,7 +30,7 @@ class MakeDagRunConfNullable(VersionChange):
instructions_to_migrate_to_previous_version = ()
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def ensure_conf_is_dict_in_dag_run(response: ResponseInfo) -> None: #
type: ignore[misc]
+ def ensure_conf_is_dict_in_dag_run(response: ResponseInfo) -> None:
"""Ensure conf is always a dict (never None) in previous versions."""
if "dag_run" in response.body and isinstance(response.body["dag_run"],
dict):
if response.body["dag_run"].get("conf") is None:
diff --git
a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_11_05.py
b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_11_05.py
index ced2917afda..c1b400e4a85 100644
--- a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_11_05.py
+++ b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2025_11_05.py
@@ -30,7 +30,7 @@ class AddTriggeringUserNameField(VersionChange):
instructions_to_migrate_to_previous_version =
(schema(DagRun).field("triggering_user_name").didnt_exist,)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def remove_triggering_user_name_from_dag_run(response: ResponseInfo) ->
None: # type: ignore[misc]
+ def remove_triggering_user_name_from_dag_run(response: ResponseInfo) ->
None:
"""Remove the `triggering_user_name` field from the dag_run object
when converting to the previous version."""
if "dag_run" in response.body and isinstance(response.body["dag_run"],
dict):
response.body["dag_run"].pop("triggering_user_name", None)
diff --git
a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_04_06.py
b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_04_06.py
index 4710de4f665..93a794ae3ef 100644
--- a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_04_06.py
+++ b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_04_06.py
@@ -48,14 +48,14 @@ class AddPartitionKeyField(VersionChange):
)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def remove_partition_key_from_dag_run(response: ResponseInfo) -> None: #
type: ignore[misc]
+ def remove_partition_key_from_dag_run(response: ResponseInfo) -> None:
"""Remove the `partition_key` field from the dag_run object when
converting to the previous version."""
dag_run = response.body.get("dag_run")
if isinstance(dag_run, dict):
dag_run.pop("partition_key", None)
@convert_response_to_previous_version_for(AssetEventsResponse) # type:
ignore[arg-type]
- def remove_partition_key_from_asset_events(response: ResponseInfo) ->
None: # type: ignore[misc]
+ def remove_partition_key_from_asset_events(response: ResponseInfo) -> None:
"""Remove the `partition_key` field from the dag_run object when
converting to the previous version."""
events = response.body["asset_events"]
for elem in events:
@@ -91,7 +91,7 @@ class MakeDagRunStartDateNullable(VersionChange):
instructions_to_migrate_to_previous_version =
(schema(DagRun).field("start_date").had(type=UtcDateTime),)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def ensure_start_date_in_ti_run_context(response: ResponseInfo) -> None:
# type: ignore[misc]
+ def ensure_start_date_in_ti_run_context(response: ResponseInfo) -> None:
"""
Ensure start_date is never None in DagRun for previous API versions.
@@ -103,7 +103,7 @@ class MakeDagRunStartDateNullable(VersionChange):
dag_run["start_date"] = dag_run.get("run_after")
@convert_response_to_previous_version_for(DagRun) # type: ignore[arg-type]
- def ensure_start_date_in_dag_run(response: ResponseInfo) -> None: # type:
ignore[misc]
+ def ensure_start_date_in_dag_run(response: ResponseInfo) -> None:
"""Ensure start_date is never None in direct DagRun responses for
previous API versions."""
if response.body.get("start_date") is None:
response.body["start_date"] = response.body.get("run_after")
@@ -120,7 +120,7 @@ class ModifyDeferredTaskKwargsToJsonValue(VersionChange):
)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def convert_next_kwargs_to_base_serialization(response: ResponseInfo) ->
None: # type: ignore[misc]
+ def convert_next_kwargs_to_base_serialization(response: ResponseInfo) ->
None:
"""
Convert next_kwargs from SDK serde format to BaseSerialization format
for old workers.
@@ -160,7 +160,7 @@ class RemoveUpstreamMapIndexesField(VersionChange):
)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def add_upstream_map_indexes_field(response: ResponseInfo) -> None: #
type: ignore[misc]
+ def add_upstream_map_indexes_field(response: ResponseInfo) -> None:
"""Add upstream_map_indexes field with None for older API versions."""
response.body["upstream_map_indexes"] = None
@@ -176,7 +176,7 @@ class AddNoteField(VersionChange):
)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def remove_note_field(response: ResponseInfo) -> None: # type:
ignore[misc]
+ def remove_note_field(response: ResponseInfo) -> None:
"""Remove note field for older API versions."""
if "dag_run" in response.body and isinstance(response.body["dag_run"],
dict):
response.body["dag_run"].pop("note", None)
@@ -190,7 +190,7 @@ class AddTaskInstanceStartDateField(VersionChange):
instructions_to_migrate_to_previous_version =
(schema(TIRunContext).field("start_date").didnt_exist,)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def remove_start_date_field(response: ResponseInfo) -> None: # type:
ignore[misc]
+ def remove_start_date_field(response: ResponseInfo) -> None:
"""Remove start_date field for older API versions."""
response.body.pop("start_date", None)
diff --git
a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_06_30.py
b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_06_30.py
index 85d46420040..b484bcd90e7 100644
--- a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_06_30.py
+++ b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_06_30.py
@@ -95,13 +95,13 @@ class AddTeamNameField(VersionChange):
instructions_to_migrate_to_previous_version =
(schema(DagRun).field("team_name").didnt_exist,)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def remove_team_name_field(response: ResponseInfo) -> None: # type:
ignore[misc]
+ def remove_team_name_field(response: ResponseInfo) -> None:
"""Remove the ``team_name`` field from dag_run for older API
versions."""
if "dag_run" in response.body and isinstance(response.body["dag_run"],
dict):
response.body["dag_run"].pop("team_name", None)
@convert_response_to_previous_version_for(DagRun) # type: ignore[arg-type]
- def remove_team_name_from_dag_run_response(response: ResponseInfo) ->
None: # type: ignore[misc]
+ def remove_team_name_from_dag_run_response(response: ResponseInfo) -> None:
"""Remove the ``team_name`` field from responses returning a DagRun
directly."""
if isinstance(response.body, dict):
response.body.pop("team_name", None)
@@ -109,7 +109,7 @@ class AddTeamNameField(VersionChange):
# Schema-based converters are matched against the route's response model
by identity, so a
# route annotated ``DagRun | None`` never matches ``DagRun`` and has to be
addressed by path.
@convert_response_to_previous_version_for("/dag-runs/previous", ["GET"])
# type: ignore[arg-type]
- def remove_team_name_from_previous_dag_run(response: ResponseInfo) ->
None: # type: ignore[misc]
+ def remove_team_name_from_previous_dag_run(response: ResponseInfo) -> None:
"""Remove the ``team_name`` field from the previous-run response."""
if isinstance(response.body, dict):
response.body.pop("team_name", None)
@@ -152,20 +152,20 @@ class AddPartitionDateField(VersionChange):
instructions_to_migrate_to_previous_version =
(schema(DagRun).field("partition_date").didnt_exist,)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def remove_partition_date_from_dag_run(response: ResponseInfo) -> None: #
type: ignore[misc]
+ def remove_partition_date_from_dag_run(response: ResponseInfo) -> None:
"""Strip ``partition_date`` from the nested ``dag_run`` payload for
older clients."""
if "dag_run" in response.body and isinstance(response.body["dag_run"],
dict):
response.body["dag_run"].pop("partition_date", None)
@convert_response_to_previous_version_for(DagRun) # type: ignore[arg-type]
- def remove_partition_date_from_dag_run_response(response: ResponseInfo) ->
None: # type: ignore[misc]
+ def remove_partition_date_from_dag_run_response(response: ResponseInfo) ->
None:
"""Strip ``partition_date`` from responses returning a DagRun
directly."""
if isinstance(response.body, dict):
response.body.pop("partition_date", None)
# See remove_team_name_from_previous_dag_run: ``DagRun | None`` needs a
path-based converter.
@convert_response_to_previous_version_for("/dag-runs/previous", ["GET"])
# type: ignore[arg-type]
- def remove_partition_date_from_previous_dag_run(response: ResponseInfo) ->
None: # type: ignore[misc]
+ def remove_partition_date_from_previous_dag_run(response: ResponseInfo) ->
None:
"""Strip ``partition_date`` from the previous-run response."""
if isinstance(response.body, dict):
response.body.pop("partition_date", None)
@@ -184,7 +184,7 @@ class AddConsumedAssetEventPartitionKeyField(VersionChange):
# ``consumed_asset_events`` to ``[]`` whenever the relationship is not
already loaded, and
# ``/run`` is the only route that loads it -- so bare ``DagRun`` responses
never carry one.
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def remove_partition_key_from_consumed_asset_events(response:
ResponseInfo) -> None: # type: ignore[misc]
+ def remove_partition_key_from_consumed_asset_events(response:
ResponseInfo) -> None:
"""Strip ``partition_key`` from each consumed asset event for older
clients."""
dag_run = response.body.get("dag_run")
if isinstance(dag_run, dict):
diff --git
a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_10_30.py
b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_10_30.py
index d6ac7dffd13..7bf2a876298 100644
--- a/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_10_30.py
+++ b/airflow-core/src/airflow/api_fastapi/execution_api/versions/v2026_10_30.py
@@ -44,7 +44,7 @@ class AddLoopContext(VersionChange):
instructions_to_migrate_to_previous_version =
(schema(TIRunContext).field("loop").didnt_exist,)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def remove_loop_context(response: ResponseInfo) -> None: # type:
ignore[misc]
+ def remove_loop_context(response: ResponseInfo) -> None:
response.body.pop("loop", None)
@@ -88,7 +88,7 @@ class
AddArgBindingsToTIRunContext(VersionChangeWithSideEffects):
instructions_to_migrate_to_previous_version =
(schema(TIRunContext).field("arg_bindings").didnt_exist,)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def remove_arg_bindings_field(response: ResponseInfo) -> None: # type:
ignore[misc]
+ def remove_arg_bindings_field(response: ResponseInfo) -> None:
"""Strip ``arg_bindings`` from the run context for older clients."""
response.body.pop("arg_bindings", None)
@@ -142,7 +142,7 @@ class AddMultiTeamToTIRunContext(VersionChange):
instructions_to_migrate_to_previous_version =
(schema(TIRunContext).field("multi_team").didnt_exist,)
@convert_response_to_previous_version_for(TIRunContext) # type:
ignore[arg-type]
- def remove_multi_team_field(response: ResponseInfo) -> None: # type:
ignore[misc]
+ def remove_multi_team_field(response: ResponseInfo) -> None:
"""Strip ``multi_team`` from the run context for older clients."""
response.body.pop("multi_team", None)
diff --git a/airflow-core/src/airflow/jobs/triggerer_job_runner.py
b/airflow-core/src/airflow/jobs/triggerer_job_runner.py
index 326eae953e4..7f39fc67e0d 100644
--- a/airflow-core/src/airflow/jobs/triggerer_job_runner.py
+++ b/airflow-core/src/airflow/jobs/triggerer_job_runner.py
@@ -557,7 +557,7 @@ class TriggerRunnerSupervisor(WatchedSubprocess):
return self._exit_code is None
@classmethod
- def start( # type: ignore[override]
+ def start(
cls,
*,
job: Job | None = None,
diff --git a/airflow-core/src/airflow/models/backfill.py
b/airflow-core/src/airflow/models/backfill.py
index 8e74f3e7fab..d3093a0583f 100644
--- a/airflow-core/src/airflow/models/backfill.py
+++ b/airflow-core/src/airflow/models/backfill.py
@@ -231,10 +231,10 @@ class Backfill(Base):
elif dialect_name == "sqlite":
duration_expr = (func.julianday(cls.completed_at) -
func.julianday(cls.created_at)) * 86400
else:
- duration_expr = func.extract("epoch", cls.completed_at -
cls.created_at) # type: ignore[operator, arg-type]
+ duration_expr = func.extract("epoch", cls.completed_at -
cls.created_at)
when_condition = (
- cls.completed_at.isnot(None) & cls.created_at.isnot(None), #
type: ignore[union-attr, attr-defined]
+ cls.completed_at.isnot(None) & cls.created_at.isnot(None),
duration_expr,
)
diff --git a/airflow-core/src/airflow/models/serialized_dag.py
b/airflow-core/src/airflow/models/serialized_dag.py
index c8fcea2d634..aa2e801d7d5 100644
--- a/airflow-core/src/airflow/models/serialized_dag.py
+++ b/airflow-core/src/airflow/models/serialized_dag.py
@@ -318,13 +318,13 @@ class SerializedDagModel(Base):
dag_runs = relationship(
DagRun,
- primaryjoin=dag_id == foreign(DagRun.dag_id), # type: ignore[has-type]
+ primaryjoin=dag_id == foreign(DagRun.dag_id),
backref=backref("serialized_dag", uselist=False, innerjoin=True),
)
dag_model = relationship(
DagModel,
- primaryjoin=dag_id == DagModel.dag_id, # type: ignore[has-type]
+ primaryjoin=dag_id == DagModel.dag_id,
foreign_keys=dag_id,
uselist=False,
innerjoin=True,
diff --git a/airflow-core/src/airflow/models/taskinstance.py
b/airflow-core/src/airflow/models/taskinstance.py
index c90deef1b60..4a0ed099426 100644
--- a/airflow-core/src/airflow/models/taskinstance.py
+++ b/airflow-core/src/airflow/models/taskinstance.py
@@ -3583,7 +3583,7 @@ def find_relevant_relatives(
continue
relative_map_indexes = _get_relevant_map_indexes(
task=task,
- relative=relative, # type: ignore[arg-type]
+ relative=relative,
run_id=run_id,
map_index=map_index,
ti_count=ti_count,
diff --git
a/airflow-core/src/airflow/serialization/definitions/mappedoperator.py
b/airflow-core/src/airflow/serialization/definitions/mappedoperator.py
index 4033152abbb..288f1673136 100644
--- a/airflow-core/src/airflow/serialization/definitions/mappedoperator.py
+++ b/airflow-core/src/airflow/serialization/definitions/mappedoperator.py
@@ -387,7 +387,7 @@ class SerializedMappedOperator(DAGNode):
from airflow import plugins_manager
operator_extra_links = plugins_manager.get_operator_extra_links()
- operator_class_type = self.operator_class["task_type"] # type: ignore
+ operator_class_type = self.operator_class["task_type"]
for ope in operator_extra_links:
if ope.operators and any(operator_class_type in cls.__name__ for
cls in ope.operators):
op_extra_links_from_plugin.update({ope.name: ope})
diff --git a/airflow-core/src/airflow/timetables/simple.py
b/airflow-core/src/airflow/timetables/simple.py
index d16627a56c8..5ced6b48fbb 100644
--- a/airflow-core/src/airflow/timetables/simple.py
+++ b/airflow-core/src/airflow/timetables/simple.py
@@ -44,7 +44,7 @@ try:
except ModuleNotFoundError:
BaseAsset: TypeAlias = SerializedAssetBase # type: ignore[no-redef]
- def ensure_serialized_asset(o): # type: ignore[misc,no-redef]
+ def ensure_serialized_asset(o): # type: ignore[no-redef]
return o
diff --git a/airflow-core/src/airflow/utils/cli_action_loggers.py
b/airflow-core/src/airflow/utils/cli_action_loggers.py
index f1f5877c72a..9a2f1274222 100644
--- a/airflow-core/src/airflow/utils/cli_action_loggers.py
+++ b/airflow-core/src/airflow/utils/cli_action_loggers.py
@@ -132,7 +132,7 @@ def default_action_log(
# Use bulk_insert_mappings here to avoid importing all models (which
using the classes does) early
# on in the CLI
session.bulk_insert_mappings(
- Log, # type: ignore[arg-type]
+ Log,
[
{
"event": f"cli_{sub_command}",
diff --git a/airflow-core/src/airflow/utils/db_cleanup.py
b/airflow-core/src/airflow/utils/db_cleanup.py
index 23ea7e41bc1..ca81c3a503f 100644
--- a/airflow-core/src/airflow/utils/db_cleanup.py
+++ b/airflow-core/src/airflow/utils/db_cleanup.py
@@ -763,7 +763,7 @@ def _build_query(
query = query.outerjoin(
subquery,
and_(
- *[base_table.c[x] == subquery.c[x] for x in
keep_last_group_by], # type: ignore[attr-defined]
+ *[base_table.c[x] == subquery.c[x] for x in
keep_last_group_by],
base_table_recency_col == column(max_date_col_name),
),
)
diff --git a/airflow-core/src/airflow/utils/memray_utils.py
b/airflow-core/src/airflow/utils/memray_utils.py
index 050d19edab6..a53538ff4ae 100644
--- a/airflow-core/src/airflow/utils/memray_utils.py
+++ b/airflow-core/src/airflow/utils/memray_utils.py
@@ -51,6 +51,8 @@ def enable_memray_trace(component: MemrayTraceComponents) ->
Callable[[Callable[
"""
def decorator(func: Callable[PS, RT]) -> Callable[PS, RT]:
+ # Keep this ignore[return]: memray's stub types Tracker.__exit__ as ->
bool, so mypy assumes
+ # exceptions may be swallowed. It only looks unused when memray isn't
installed (CI installs it).
@wraps(func)
def wrapper(*args: PS.args, **kwargs: PS.kwargs) -> RT: # type:
ignore[return]
_memray_trace_components = conf.getenumlist(
diff --git a/airflow-core/src/airflow/utils/retries.py
b/airflow-core/src/airflow/utils/retries.py
index 69b71046acb..c9d8c466203 100644
--- a/airflow-core/src/airflow/utils/retries.py
+++ b/airflow-core/src/airflow/utils/retries.py
@@ -48,7 +48,7 @@ def run_with_db_retries(max_retries: int = MAX_DB_RETRIES,
logger: Logger | None
**kwargs,
)
if logger is not None:
- retry_kwargs["before_sleep"] = tenacity.before_sleep_log(logger,
logging.DEBUG, True) # type: ignore[arg-type]
+ retry_kwargs["before_sleep"] = tenacity.before_sleep_log(logger,
logging.DEBUG, True)
return tenacity.Retrying(**retry_kwargs)
diff --git a/airflow-core/tests/unit/cli/commands/test_dag_command.py
b/airflow-core/tests/unit/cli/commands/test_dag_command.py
index 11637bafa46..ff97b2fe716 100644
--- a/airflow-core/tests/unit/cli/commands/test_dag_command.py
+++ b/airflow-core/tests/unit/cli/commands/test_dag_command.py
@@ -1326,7 +1326,7 @@ class TestCliDags:
try:
from airflow.utils.cli import get_bagged_dag
except ImportError: # Prior to Airflow 3.1.0.
- from airflow.utils.cli import get_dag as get_bagged_dag # type:
ignore
+ from airflow.utils.cli import get_dag as get_bagged_dag
with configure_testing_dag_bundle(TEST_DAGS_FOLDER / "test_sensor.py"):
# example DAG should not be found since the testing bundle only
exposes test_sensor.py
diff --git a/airflow-core/tests/unit/executors/test_base_executor.py
b/airflow-core/tests/unit/executors/test_base_executor.py
index a44cde67846..d2c769d2943 100644
--- a/airflow-core/tests/unit/executors/test_base_executor.py
+++ b/airflow-core/tests/unit/executors/test_base_executor.py
@@ -677,7 +677,7 @@ def
test_queued_tasks_setter_emits_warning_and_writes_through():
executor = BaseExecutor()
new_queue = {"k": "v"}
with pytest.warns(RemovedInAirflow4Warning, match="queued_tasks is
deprecated"):
- executor.queued_tasks = new_queue # type: ignore[misc]
+ executor.queued_tasks = new_queue
assert executor.executor_queues[WorkloadType.EXECUTE_TASK] is new_queue
@@ -685,7 +685,7 @@ def
test_queued_callbacks_setter_emits_warning_and_writes_through():
executor = BaseExecutor()
new_queue = {"k": "v"}
with pytest.warns(RemovedInAirflow4Warning, match="queued_callbacks is
deprecated"):
- executor.queued_callbacks = new_queue # type: ignore[misc]
+ executor.queued_callbacks = new_queue
assert executor.executor_queues[WorkloadType.EXECUTE_CALLBACK] is new_queue
@@ -743,7 +743,7 @@ def
test_unknown_workload_type_sorts_last_without_crashing():
unknown_workload.type = "SomeFutureType"
unknown_workload.sort_key = 0
executor.executor_queues[WorkloadType.EXECUTE_TASK][known_key] =
known_workload
- executor.executor_queues["SomeFutureType"]["unk"] = unknown_workload #
type: ignore[index]
+ executor.executor_queues["SomeFutureType"]["unk"] = unknown_workload
scheduled = executor._get_workloads_to_schedule(open_slots=10)
diff --git a/airflow-core/tests/unit/executors/test_workloads.py
b/airflow-core/tests/unit/executors/test_workloads.py
index 25753f2f50a..dafcbbdede6 100644
--- a/airflow-core/tests/unit/executors/test_workloads.py
+++ b/airflow-core/tests/unit/executors/test_workloads.py
@@ -265,7 +265,7 @@ def test_callback_key_is_frozen_and_hashable():
# Frozen: assignment raises
with pytest.raises(dataclasses.FrozenInstanceError):
- key.id = "mutated" # type: ignore[misc]
+ key.id = "mutated"
def test_callback_key_str_returns_id():
@@ -287,7 +287,7 @@ def test_state_class_for_key_raises_on_unknown_type():
"""state_class_for_key should raise TypeError for unrecognized key
types."""
with pytest.raises(TypeError, match="Unknown workload key type"):
- state_class_for_key("bare-string-is-not-a-key") # type:
ignore[arg-type]
+ state_class_for_key("bare-string-is-not-a-key")
def test_callback_dto_key_returns_callback_key_instance():
diff --git a/airflow-core/tests/unit/migrations/test_migration_patterns.py
b/airflow-core/tests/unit/migrations/test_migration_patterns.py
index b6bb0abc0ea..4b941ac33f2 100644
--- a/airflow-core/tests/unit/migrations/test_migration_patterns.py
+++ b/airflow-core/tests/unit/migrations/test_migration_patterns.py
@@ -32,7 +32,7 @@ if _spec is None or _spec.loader is None:
_mod = importlib.util.module_from_spec(_spec)
# Register in sys.modules before exec so dataclasses can resolve the module
via cls.__module__
sys.modules["check_migration_patterns"] = _mod
-_spec.loader.exec_module(_mod) # type: ignore[union-attr] # typeshed: Loader
lacks exec_module
+_spec.loader.exec_module(_mod) # typeshed: Loader lacks exec_module
MigrationFile = _mod.MigrationFile
check_mig001 = _mod.check_mig001
check_mig002 = _mod.check_mig002
diff --git a/airflow-core/tests/unit/models/test_connection_test.py
b/airflow-core/tests/unit/models/test_connection_test.py
index 3cce66c3c01..f3041a20685 100644
--- a/airflow-core/tests/unit/models/test_connection_test.py
+++ b/airflow-core/tests/unit/models/test_connection_test.py
@@ -55,7 +55,7 @@ class TestConnectionTestKey:
def test_is_frozen(self):
key = ConnectionTestKey(id="abc")
with pytest.raises(dataclasses.FrozenInstanceError):
- key.id = "xyz" # type: ignore[misc]
+ key.id = "xyz"
def test_not_a_str_instance(self):
assert not isinstance(ConnectionTestKey(id="abc"), str)
diff --git a/airflow-core/tests/unit/plugins/test_plugins_manager.py
b/airflow-core/tests/unit/plugins/test_plugins_manager.py
index fc52a901849..e1194539461 100644
--- a/airflow-core/tests/unit/plugins/test_plugins_manager.py
+++ b/airflow-core/tests/unit/plugins/test_plugins_manager.py
@@ -275,8 +275,8 @@ class TestPluginsManager:
name = "test_plugin_a"
# Malformed on purpose to trigger the warning path; mypy ignores
below.
- external_views = [[{"nested_list": "/test_route"}], {"url_route":
"/test_route"}] # type: ignore[list-item, typeddict-item]
- react_apps = [[{"nested_list": "/test_route"}], {"url_route":
"/test_route_react_app"}] # type: ignore[list-item, typeddict-item]
+ external_views = [[{"nested_list": "/test_route"}], {"url_route":
"/test_route"}] # type: ignore[typeddict-item]
+ react_apps = [[{"nested_list": "/test_route"}], {"url_route":
"/test_route_react_app"}] # type: ignore[typeddict-item]
with (
mock_plugin_manager(plugins=[TestPluginA()]),
diff --git a/airflow-core/tests/unit/utils/test_db_manager.py
b/airflow-core/tests/unit/utils/test_db_manager.py
index 513ecf5855c..7f26fafc91e 100644
--- a/airflow-core/tests/unit/utils/test_db_manager.py
+++ b/airflow-core/tests/unit/utils/test_db_manager.py
@@ -232,7 +232,7 @@ class TestBaseDBManager:
manager = CustomDBManager(session)
with pytest.raises(TypeError):
# Ensure the old kwarg name is not accepted anymore
- manager.downgrade(to_version="1.2.3") # type: ignore[call-arg]
+ manager.downgrade(to_version="1.2.3")
@mock.patch("airflow.utils.db.create_global_lock",
return_value=nullcontext())
@mock.patch.object(MockDBManager, "drop_tables")