Skip to content

Commit 6ae0a80

Browse files
ashburanusjr
andauthored
Upgrade mypy to 0.991 (#28926)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
1 parent 1f2b383 commit 6ae0a80

39 files changed

+108
-62
lines changed

β€Ž.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ repos:
160160
entry: ./scripts/ci/pre_commit/pre_commit_update_common_sql_api_stubs.py
161161
language: python
162162
files: ^scripts/ci/pre_commit/pre_commit_update_common_sql_api\.py|^airflow/providers/common/sql/.*\.pyi?$
163-
additional_dependencies: ['rich>=12.4.4', 'mypy==0.971', 'black==22.12.0', 'jinja2']
163+
additional_dependencies: ['rich>=12.4.4', 'mypy==0.991', 'black==22.12.0', 'jinja2']
164164
pass_filenames: false
165165
require_serial: true
166166
- id: update-black-version

β€Žairflow/dag_processing/manager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ def __init__(
141141

142142
def start(self) -> None:
143143
"""Launch DagFileProcessorManager processor and start DAG parsing loop in manager."""
144-
mp_start_method = self._get_multiprocessing_start_method()
145-
context = multiprocessing.get_context(mp_start_method)
144+
context = self._get_multiprocessing_context()
146145
self._last_parsing_stat_received_at = time.monotonic()
147146

148147
self._parent_signal_conn, child_signal_conn = context.Pipe()

β€Žairflow/dag_processing/processor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ def _handle_dag_file_processing():
187187

188188
def start(self) -> None:
189189
"""Launch the process and start processing the DAG."""
190-
start_method = self._get_multiprocessing_start_method()
191-
context = multiprocessing.get_context(start_method)
190+
context = self._get_multiprocessing_context()
192191

193192
_parent_channel, _child_channel = context.Pipe(duplex=False)
194193
process = context.Process(

β€Žairflow/decorators/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def _get_unmap_kwargs(self, mapped_kwargs: Mapping[str, Any], *, strict: bool) -
489489
return super()._get_unmap_kwargs(kwargs, strict=False)
490490

491491

492-
class Task(Generic[FParams, FReturn]):
492+
class Task(Protocol, Generic[FParams, FReturn]):
493493
"""Declaration of a @task-decorated callable for type-checking.
494494
495495
An instance of this type inherits the call signature of the decorated

β€Žairflow/example_dags/plugins/workday.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def next_dagrun_info(
7878

7979
# [END howto_timetable_next_dagrun_info]
8080

81+
def validate(self):
82+
pass
83+
8184

8285
class WorkdayTimetablePlugin(AirflowPlugin):
8386
name = "workday_timetable_plugin"

β€Žairflow/executors/kubernetes_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
class ResourceVersion:
7070
"""Singleton for tracking resourceVersion from Kubernetes."""
7171

72-
_instance = None
72+
_instance: ResourceVersion | None = None
7373
resource_version: dict[str, str] = {}
7474

7575
def __new__(cls):

β€Žairflow/hooks/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ def get_conn(self) -> Any:
9090

9191
@classmethod
9292
def get_connection_form_widgets(cls) -> dict[str, Any]:
93-
...
93+
return {}
9494

9595
@classmethod
9696
def get_ui_field_behaviour(cls) -> dict[str, Any]:
97-
...
97+
return {}
9898

9999

100100
class DiscoverableHook(Protocol):

β€Žairflow/listeners/listener.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
log = logging.getLogger(__name__)
3131

3232

33-
_listener_manager = None
33+
_listener_manager: ListenerManager | None = None
3434

3535

3636
class ListenerManager:

β€Žairflow/models/baseoperator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from abc import ABCMeta, abstractmethod
3131
from datetime import datetime, timedelta
3232
from inspect import signature
33-
from types import FunctionType
33+
from types import ClassMethodDescriptorType, FunctionType
3434
from typing import (
3535
TYPE_CHECKING,
3636
Any,
@@ -169,7 +169,7 @@ def get_merged_defaults(
169169
class _PartialDescriptor:
170170
"""A descriptor that guards against ``.partial`` being called on Task objects."""
171171

172-
class_method = None
172+
class_method: ClassMethodDescriptorType | None = None
173173

174174
def __get__(
175175
self, obj: BaseOperator, cls: type[BaseOperator] | None = None

β€Žairflow/providers/google/cloud/hooks/cloud_sql.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,6 @@ class CloudSQLDatabaseHook(BaseHook):
691691
conn_type = "gcpcloudsqldb"
692692
hook_name = "Google Cloud SQL Database"
693693

694-
_conn = None
695-
696694
def __init__(
697695
self,
698696
gcp_cloudsql_conn_id: str = "google_cloud_sql_default",

0 commit comments

Comments
 (0)