You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/02/11 00:46:50 UTC
[airflow] branch main updated: Revert "Upgrade mypy to 0.991 (#28926)" (#29470)
This is an automated email from the ASF dual-hosted git repository.
potiuk 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 6c1eeb5839 Revert "Upgrade mypy to 0.991 (#28926)" (#29470)
6c1eeb5839 is described below
commit 6c1eeb58393173895944d5414793b38abdc7510d
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Sat Feb 11 01:46:42 2023 +0100
Revert "Upgrade mypy to 0.991 (#28926)" (#29470)
This reverts commit 6ae0a80cbaf1d33343b763c7f82612b4522afc40.
---
.pre-commit-config.yaml | 2 +-
airflow/dag_processing/manager.py | 3 ++-
airflow/dag_processing/processor.py | 3 ++-
airflow/decorators/base.py | 2 +-
airflow/example_dags/plugins/workday.py | 3 ---
airflow/executors/kubernetes_executor.py | 2 +-
airflow/hooks/base.py | 4 ++--
airflow/listeners/listener.py | 2 +-
airflow/models/baseoperator.py | 4 ++--
airflow/providers/google/cloud/hooks/cloud_sql.py | 2 ++
airflow/providers/google/cloud/hooks/functions.py | 2 +-
airflow/providers/google/cloud/hooks/gcs.py | 18 ++++------------
.../providers/google/cloud/hooks/life_sciences.py | 2 +-
.../google/cloud/utils/field_validator.py | 2 +-
.../providers/google/firebase/hooks/firestore.py | 2 +-
.../google/marketing_platform/hooks/search_ads.py | 2 +-
airflow/providers/microsoft/psrp/hooks/psrp.py | 3 ++-
airflow/settings.py | 2 +-
airflow/stats.py | 7 +++---
airflow/timetables/simple.py | 3 ---
airflow/utils/mixins.py | 6 ------
airflow/utils/session.py | 2 +-
airflow/utils/state.py | 2 +-
airflow/www/extensions/init_appbuilder.py | 2 --
airflow/www/fab_security/manager.py | 2 --
dev/breeze/src/airflow_breeze/utils/click_utils.py | 2 +-
.../pre_commit_check_order_dockerfile_extras.py | 2 +-
.../ci/pre_commit/pre_commit_check_order_setup.py | 2 +-
...re_commit_check_system_tests_hidden_in_index.py | 3 +--
.../pre_commit_update_common_sql_api_stubs.py | 25 +++++++++-------------
.../in_container/run_provider_yaml_files_check.py | 2 +-
setup.cfg | 7 ------
setup.py | 2 +-
tests/listeners/dag_listener.py | 4 +---
tests/listeners/full_listener.py | 8 +++----
tests/listeners/lifecycle_listener.py | 6 ++----
tests/listeners/partial_listener.py | 2 +-
tests/test_utils/timetables.py | 9 --------
tests/www/views/test_views_connection.py | 12 +++++++----
39 files changed, 62 insertions(+), 108 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9acd241f74..6499584074 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -160,7 +160,7 @@ repos:
entry: ./scripts/ci/pre_commit/pre_commit_update_common_sql_api_stubs.py
language: python
files: ^scripts/ci/pre_commit/pre_commit_update_common_sql_api\.py|^airflow/providers/common/sql/.*\.pyi?$
- additional_dependencies: ['rich>=12.4.4', 'mypy==0.991', 'black==22.12.0', 'jinja2']
+ additional_dependencies: ['rich>=12.4.4', 'mypy==0.971', 'black==22.12.0', 'jinja2']
pass_filenames: false
require_serial: true
- id: update-black-version
diff --git a/airflow/dag_processing/manager.py b/airflow/dag_processing/manager.py
index 2246e7f3a7..232d0d7e62 100644
--- a/airflow/dag_processing/manager.py
+++ b/airflow/dag_processing/manager.py
@@ -141,7 +141,8 @@ class DagFileProcessorAgent(LoggingMixin, MultiprocessingStartMethodMixin):
def start(self) -> None:
"""Launch DagFileProcessorManager processor and start DAG parsing loop in manager."""
- context = self._get_multiprocessing_context()
+ mp_start_method = self._get_multiprocessing_start_method()
+ context = multiprocessing.get_context(mp_start_method)
self._last_parsing_stat_received_at = time.monotonic()
self._parent_signal_conn, child_signal_conn = context.Pipe()
diff --git a/airflow/dag_processing/processor.py b/airflow/dag_processing/processor.py
index 62441c2b5b..bce6fb9148 100644
--- a/airflow/dag_processing/processor.py
+++ b/airflow/dag_processing/processor.py
@@ -187,7 +187,8 @@ class DagFileProcessorProcess(LoggingMixin, MultiprocessingStartMethodMixin):
def start(self) -> None:
"""Launch the process and start processing the DAG."""
- context = self._get_multiprocessing_context()
+ start_method = self._get_multiprocessing_start_method()
+ context = multiprocessing.get_context(start_method)
_parent_channel, _child_channel = context.Pipe(duplex=False)
process = context.Process(
diff --git a/airflow/decorators/base.py b/airflow/decorators/base.py
index b15acba877..7da74e5514 100644
--- a/airflow/decorators/base.py
+++ b/airflow/decorators/base.py
@@ -489,7 +489,7 @@ class DecoratedMappedOperator(MappedOperator):
return super()._get_unmap_kwargs(kwargs, strict=False)
-class Task(Protocol, Generic[FParams, FReturn]):
+class Task(Generic[FParams, FReturn]):
"""Declaration of a @task-decorated callable for type-checking.
An instance of this type inherits the call signature of the decorated
diff --git a/airflow/example_dags/plugins/workday.py b/airflow/example_dags/plugins/workday.py
index 25f7a8c9cc..db68c29541 100644
--- a/airflow/example_dags/plugins/workday.py
+++ b/airflow/example_dags/plugins/workday.py
@@ -78,9 +78,6 @@ class AfterWorkdayTimetable(Timetable):
# [END howto_timetable_next_dagrun_info]
- def validate(self):
- pass
-
class WorkdayTimetablePlugin(AirflowPlugin):
name = "workday_timetable_plugin"
diff --git a/airflow/executors/kubernetes_executor.py b/airflow/executors/kubernetes_executor.py
index 962e64cd48..b388a3b386 100644
--- a/airflow/executors/kubernetes_executor.py
+++ b/airflow/executors/kubernetes_executor.py
@@ -69,7 +69,7 @@ KubernetesWatchType = Tuple[str, str, Optional[str], Dict[str, str], str]
class ResourceVersion:
"""Singleton for tracking resourceVersion from Kubernetes."""
- _instance: ResourceVersion | None = None
+ _instance = None
resource_version: dict[str, str] = {}
def __new__(cls):
diff --git a/airflow/hooks/base.py b/airflow/hooks/base.py
index c1c758a756..9298a68688 100644
--- a/airflow/hooks/base.py
+++ b/airflow/hooks/base.py
@@ -90,11 +90,11 @@ class BaseHook(LoggingMixin):
@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
- return {}
+ ...
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
- return {}
+ ...
class DiscoverableHook(Protocol):
diff --git a/airflow/listeners/listener.py b/airflow/listeners/listener.py
index dd5481cba1..546d732513 100644
--- a/airflow/listeners/listener.py
+++ b/airflow/listeners/listener.py
@@ -30,7 +30,7 @@ if TYPE_CHECKING:
log = logging.getLogger(__name__)
-_listener_manager: ListenerManager | None = None
+_listener_manager = None
class ListenerManager:
diff --git a/airflow/models/baseoperator.py b/airflow/models/baseoperator.py
index 2b28975c5f..10c55d5b63 100644
--- a/airflow/models/baseoperator.py
+++ b/airflow/models/baseoperator.py
@@ -30,7 +30,7 @@ import warnings
from abc import ABCMeta, abstractmethod
from datetime import datetime, timedelta
from inspect import signature
-from types import ClassMethodDescriptorType, FunctionType
+from types import FunctionType
from typing import (
TYPE_CHECKING,
Any,
@@ -169,7 +169,7 @@ def get_merged_defaults(
class _PartialDescriptor:
"""A descriptor that guards against ``.partial`` being called on Task objects."""
- class_method: ClassMethodDescriptorType | None = None
+ class_method = None
def __get__(
self, obj: BaseOperator, cls: type[BaseOperator] | None = None
diff --git a/airflow/providers/google/cloud/hooks/cloud_sql.py b/airflow/providers/google/cloud/hooks/cloud_sql.py
index 15c8fed148..7f96d63156 100644
--- a/airflow/providers/google/cloud/hooks/cloud_sql.py
+++ b/airflow/providers/google/cloud/hooks/cloud_sql.py
@@ -691,6 +691,8 @@ class CloudSQLDatabaseHook(BaseHook):
conn_type = "gcpcloudsqldb"
hook_name = "Google Cloud SQL Database"
+ _conn = None
+
def __init__(
self,
gcp_cloudsql_conn_id: str = "google_cloud_sql_default",
diff --git a/airflow/providers/google/cloud/hooks/functions.py b/airflow/providers/google/cloud/hooks/functions.py
index 084d6fb06a..3ed62a75dd 100644
--- a/airflow/providers/google/cloud/hooks/functions.py
+++ b/airflow/providers/google/cloud/hooks/functions.py
@@ -40,7 +40,7 @@ class CloudFunctionsHook(GoogleBaseHook):
keyword arguments rather than positional.
"""
- _conn: build | None = None
+ _conn = None
def __init__(
self,
diff --git a/airflow/providers/google/cloud/hooks/gcs.py b/airflow/providers/google/cloud/hooks/gcs.py
index ceaa202a00..e7ef1210ec 100644
--- a/airflow/providers/google/cloud/hooks/gcs.py
+++ b/airflow/providers/google/cloud/hooks/gcs.py
@@ -51,18 +51,8 @@ from airflow.providers.google.common.hooks.base_google import GoogleBaseAsyncHoo
from airflow.utils import timezone
from airflow.version import version
-try:
- # Airflow 2.3 doesn't have this yet
- from airflow.typing_compat import ParamSpec
-except ImportError:
- try:
- from typing import ParamSpec # type: ignore[no-redef,attr-defined]
- except ImportError:
- from typing_extensions import ParamSpec
-
RT = TypeVar("RT")
T = TypeVar("T", bound=Callable)
-FParams = ParamSpec("FParams")
# GCSHook has a method named 'list' (to junior devs: please don't do this), so
# we need to create an alias to prevent Mypy being confused.
@@ -86,7 +76,7 @@ def _fallback_object_url_to_object_name_and_bucket_name(
:return: Decorator
"""
- def _wrapper(func: Callable[FParams, RT]) -> Callable[FParams, RT]:
+ def _wrapper(func: T):
@functools.wraps(func)
def _inner_wrapper(self: GCSHook, *args, **kwargs) -> RT:
if args:
@@ -127,11 +117,11 @@ def _fallback_object_url_to_object_name_and_bucket_name(
f"'{bucket_name_keyword_arg_name}'"
)
- return func(self, *args, **kwargs) # type: ignore
+ return func(self, *args, **kwargs)
- return cast(Callable[FParams, RT], _inner_wrapper)
+ return cast(T, _inner_wrapper)
- return cast(Callable[[T], T], _wrapper)
+ return _wrapper
# A fake bucket to use in functions decorated by _fallback_object_url_to_object_name_and_bucket_name.
diff --git a/airflow/providers/google/cloud/hooks/life_sciences.py b/airflow/providers/google/cloud/hooks/life_sciences.py
index 24ad1792ac..00ed37e411 100644
--- a/airflow/providers/google/cloud/hooks/life_sciences.py
+++ b/airflow/providers/google/cloud/hooks/life_sciences.py
@@ -54,7 +54,7 @@ class LifeSciencesHook(GoogleBaseHook):
account from the list granting this role to the originating account.
"""
- _conn: build | None = None
+ _conn = None
def __init__(
self,
diff --git a/airflow/providers/google/cloud/utils/field_validator.py b/airflow/providers/google/cloud/utils/field_validator.py
index 499cb0f7e3..70ad1827af 100644
--- a/airflow/providers/google/cloud/utils/field_validator.py
+++ b/airflow/providers/google/cloud/utils/field_validator.py
@@ -206,7 +206,7 @@ class GcpBodyFieldValidator(LoggingMixin):
full_field_path: str,
regexp: str,
allow_empty: bool,
- custom_validation: Callable | None,
+ custom_validation: Callable,
value,
) -> None:
if value is None and field_type != "union":
diff --git a/airflow/providers/google/firebase/hooks/firestore.py b/airflow/providers/google/firebase/hooks/firestore.py
index 2cf36eabc0..f55f13f264 100644
--- a/airflow/providers/google/firebase/hooks/firestore.py
+++ b/airflow/providers/google/firebase/hooks/firestore.py
@@ -53,7 +53,7 @@ class CloudFirestoreHook(GoogleBaseHook):
account from the list granting this role to the originating account.
"""
- _conn: build | None = None
+ _conn = None
def __init__(
self,
diff --git a/airflow/providers/google/marketing_platform/hooks/search_ads.py b/airflow/providers/google/marketing_platform/hooks/search_ads.py
index 859878c0f1..8115833b1a 100644
--- a/airflow/providers/google/marketing_platform/hooks/search_ads.py
+++ b/airflow/providers/google/marketing_platform/hooks/search_ads.py
@@ -28,7 +28,7 @@ from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
class GoogleSearchAdsHook(GoogleBaseHook):
"""Hook for Google Search Ads 360."""
- _conn: build | None = None
+ _conn = None
def __init__(
self,
diff --git a/airflow/providers/microsoft/psrp/hooks/psrp.py b/airflow/providers/microsoft/psrp/hooks/psrp.py
index c6cd54f45a..4e4518609f 100644
--- a/airflow/providers/microsoft/psrp/hooks/psrp.py
+++ b/airflow/providers/microsoft/psrp/hooks/psrp.py
@@ -75,7 +75,8 @@ class PsrpHook(BaseHook):
or by setting this key as the extra fields of your connection.
"""
- _conn: RunspacePool | None = None
+ _conn = None
+ _configuration_name = None
_wsman_ref: WeakKeyDictionary[RunspacePool, WSMan] = WeakKeyDictionary()
def __init__(
diff --git a/airflow/settings.py b/airflow/settings.py
index 436ba4b077..64678b8018 100644
--- a/airflow/settings.py
+++ b/airflow/settings.py
@@ -411,7 +411,7 @@ def dispose_orm():
global engine
global Session
- if Session is not None:
+ if Session:
Session.remove()
Session = None
if engine:
diff --git a/airflow/stats.py b/airflow/stats.py
index 7b70ce345f..d2708f1e13 100644
--- a/airflow/stats.py
+++ b/airflow/stats.py
@@ -74,10 +74,9 @@ class StatsLogger(Protocol):
@classmethod
def timer(cls, *args, **kwargs) -> TimerProtocol:
"""Timer metric that can be cancelled."""
- raise NotImplementedError()
-class Timer(TimerProtocol):
+class Timer:
"""
Timer that records duration, and optional sends to StatsD backend.
@@ -361,7 +360,7 @@ class SafeDogStatsdLogger:
class _Stats(type):
- factory: Callable[[], StatsLogger]
+ factory = None
instance: StatsLogger | None = None
def __getattr__(cls, name):
@@ -375,7 +374,7 @@ class _Stats(type):
def __init__(cls, *args, **kwargs):
super().__init__(cls)
- if not hasattr(cls.__class__, "factory"):
+ if cls.__class__.factory is None:
is_datadog_enabled_defined = conf.has_option("metrics", "statsd_datadog_enabled")
if is_datadog_enabled_defined and conf.getboolean("metrics", "statsd_datadog_enabled"):
cls.__class__.factory = cls.get_dogstatsd_logger
diff --git a/airflow/timetables/simple.py b/airflow/timetables/simple.py
index 05595f6343..3ddd31b691 100644
--- a/airflow/timetables/simple.py
+++ b/airflow/timetables/simple.py
@@ -55,9 +55,6 @@ class _TrivialTimetable(Timetable):
def infer_manual_data_interval(self, *, run_after: DateTime) -> DataInterval:
return DataInterval.exact(run_after)
- def validate(self):
- pass
-
class NullTimetable(_TrivialTimetable):
"""Timetable that never schedules anything.
diff --git a/airflow/utils/mixins.py b/airflow/utils/mixins.py
index d157c7f078..ff28407094 100644
--- a/airflow/utils/mixins.py
+++ b/airflow/utils/mixins.py
@@ -25,8 +25,6 @@ from airflow.configuration import conf
from airflow.utils.context import Context
if typing.TYPE_CHECKING:
- import multiprocessing.context
-
from airflow.models.operator import Operator
@@ -46,10 +44,6 @@ class MultiprocessingStartMethodMixin:
raise ValueError("Failed to determine start method")
return method
- def _get_multiprocessing_context(self) -> multiprocessing.context.DefaultContext:
- mp_start_method = self._get_multiprocessing_start_method()
- return multiprocessing.get_context(mp_start_method) # type: ignore
-
class ResolveMixin:
"""A runtime-resolved value."""
diff --git a/airflow/utils/session.py b/airflow/utils/session.py
index a11462b945..f48eab9ed0 100644
--- a/airflow/utils/session.py
+++ b/airflow/utils/session.py
@@ -28,7 +28,7 @@ from airflow.typing_compat import ParamSpec
@contextlib.contextmanager
def create_session() -> Generator[settings.SASession, None, None]:
"""Contextmanager that will create and teardown a session."""
- if not hasattr(settings, "Session") or settings.Session is None:
+ if not settings.Session:
raise RuntimeError("Session must be set before!")
session = settings.Session()
try:
diff --git a/airflow/utils/state.py b/airflow/utils/state.py
index 780a3bbe60..6558af9f2a 100644
--- a/airflow/utils/state.py
+++ b/airflow/utils/state.py
@@ -85,7 +85,7 @@ class State:
FAILED = TaskInstanceState.FAILED
# These are TaskState only
- NONE: None = None
+ NONE = None
REMOVED = TaskInstanceState.REMOVED
SCHEDULED = TaskInstanceState.SCHEDULED
QUEUED = TaskInstanceState.QUEUED
diff --git a/airflow/www/extensions/init_appbuilder.py b/airflow/www/extensions/init_appbuilder.py
index fe1ae0938d..acd12b319f 100644
--- a/airflow/www/extensions/init_appbuilder.py
+++ b/airflow/www/extensions/init_appbuilder.py
@@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-
-# mypy: disable-error-code=var-annotated
from __future__ import annotations
import logging
diff --git a/airflow/www/fab_security/manager.py b/airflow/www/fab_security/manager.py
index a23315b814..ea8918053c 100644
--- a/airflow/www/fab_security/manager.py
+++ b/airflow/www/fab_security/manager.py
@@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-
-# mypy: disable-error-code=var-annotated
from __future__ import annotations
import base64
diff --git a/dev/breeze/src/airflow_breeze/utils/click_utils.py b/dev/breeze/src/airflow_breeze/utils/click_utils.py
index 46b7e8845f..d6ce5f1255 100644
--- a/dev/breeze/src/airflow_breeze/utils/click_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/click_utils.py
@@ -19,4 +19,4 @@ from __future__ import annotations
try:
from rich_click import RichGroup as BreezeGroup
except ImportError:
- from click import Group as BreezeGroup # type: ignore[assignment] # noqa
+ from click import Group as BreezeGroup # type: ignore[misc] # noqa
diff --git a/scripts/ci/pre_commit/pre_commit_check_order_dockerfile_extras.py b/scripts/ci/pre_commit/pre_commit_check_order_dockerfile_extras.py
index 37b41fc148..b3a9683280 100755
--- a/scripts/ci/pre_commit/pre_commit_check_order_dockerfile_extras.py
+++ b/scripts/ci/pre_commit/pre_commit_check_order_dockerfile_extras.py
@@ -28,7 +28,7 @@ from pathlib import Path
from rich import print
-errors: list[str] = []
+errors = []
MY_DIR_PATH = Path(__file__).parent.resolve()
diff --git a/scripts/ci/pre_commit/pre_commit_check_order_setup.py b/scripts/ci/pre_commit/pre_commit_check_order_setup.py
index 05b8136e4b..ffcb0e0e80 100755
--- a/scripts/ci/pre_commit/pre_commit_check_order_setup.py
+++ b/scripts/ci/pre_commit/pre_commit_check_order_setup.py
@@ -30,7 +30,7 @@ from os.path import abspath, dirname
from rich import print
-errors: list[str] = []
+errors = []
MY_DIR_PATH = os.path.dirname(__file__)
SOURCE_DIR_PATH = os.path.abspath(os.path.join(MY_DIR_PATH, os.pardir, os.pardir, os.pardir))
diff --git a/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py b/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py
index 5765b5a793..c8adab41b4 100755
--- a/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py
+++ b/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py
@@ -19,7 +19,6 @@ from __future__ import annotations
import sys
from pathlib import Path
-from typing import Any
from rich.console import Console
@@ -38,7 +37,7 @@ DOCS_ROOT = AIRFLOW_SOURCES_ROOT / "docs"
PREFIX = "apache-airflow-providers-"
-errors: list[Any] = []
+errors = []
def check_system_test_entry_hidden(provider_index: Path):
diff --git a/scripts/ci/pre_commit/pre_commit_update_common_sql_api_stubs.py b/scripts/ci/pre_commit/pre_commit_update_common_sql_api_stubs.py
index 357ed6c856..80a7f081da 100755
--- a/scripts/ci/pre_commit/pre_commit_update_common_sql_api_stubs.py
+++ b/scripts/ci/pre_commit/pre_commit_update_common_sql_api_stubs.py
@@ -36,10 +36,11 @@ if __name__ not in ("__main__", "__mp_main__"):
sys.path.insert(0, str(Path(__file__).parent.resolve())) # make sure common_precommit_utils is imported
-from common_precommit_utils import AIRFLOW_SOURCES_ROOT_PATH # isort: skip # noqa: E402
-from common_precommit_black_utils import black_format # isort: skip # noqa: E402
+from common_precommit_utils import AIRFLOW_SOURCES_ROOT_PATH # isort: skip # noqa E402
+from common_precommit_black_utils import black_format # isort: skip # noqa E402
-COMMON_SQL_ROOT = AIRFLOW_SOURCES_ROOT_PATH.joinpath("airflow", "providers", "common", "sql")
+PROVIDERS_ROOT = AIRFLOW_SOURCES_ROOT_PATH / "airflow" / "providers"
+COMMON_SQL_ROOT = PROVIDERS_ROOT / "common" / "sql"
OUT_DIR = AIRFLOW_SOURCES_ROOT_PATH / "out"
COMMON_SQL_PACKAGE_PREFIX = "airflow.providers.common.sql."
@@ -109,7 +110,7 @@ def post_process_line(stub_file_path: Path, line: str, new_lines: list[str]) ->
:param line: line to post-process
:param new_lines: new_lines - this is where we add post-processed lines
"""
- if stub_file_path.parts[-4:] == ("common", "sql", "operators", "sql.pyi"):
+ if stub_file_path.relative_to(OUT_DIR) == Path("common") / "sql" / "operators" / "sql.pyi":
stripped_line = line.strip()
if stripped_line.startswith("parse_boolean: Incomplete"):
# Handle Special case - historically we allow _parse_boolean to be part of the public API,
@@ -192,7 +193,7 @@ def read_pyi_file_content(
lines_no_comments = [
line
for line in pyi_file_path.read_text(encoding="utf-8").splitlines()
- if not line.strip().startswith("#")
+ if line.strip() and not line.strip().startswith("#")
]
remove_docstring = False
lines = []
@@ -205,8 +206,6 @@ def read_pyi_file_content(
if (pyi_file_path.name == "__init__.pyi") and lines == []:
console.print(f"[yellow]Skip {pyi_file_path} as it is an empty stub for __init__.py file")
return None
- if lines and not lines[-1].endswith("\n"):
- lines[-1] += "\n"
return post_process_generated_stub_file(
module_name, pyi_file_path, lines, patch_generated_file=patch_generated_files
)
@@ -221,8 +220,8 @@ def compare_stub_files(generated_stub_path: Path, force_override: bool) -> tuple
"""
_removals, _additions = 0, 0
rel_path = generated_stub_path.relative_to(OUT_DIR)
- stub_file_target_path = AIRFLOW_SOURCES_ROOT_PATH / rel_path
- module_name = os.fspath(rel_path.with_suffix("")).replace(os.path.sep, ".")
+ stub_file_target_path = PROVIDERS_ROOT / rel_path
+ module_name = "airflow.providers." + os.fspath(rel_path.with_suffix("")).replace(os.path.sep, ".")
generated_pyi_content = read_pyi_file_content(
module_name, generated_stub_path, patch_generated_files=True
)
@@ -334,11 +333,7 @@ if __name__ == "__main__":
shutil.rmtree(OUT_DIR, ignore_errors=True)
subprocess.run(
- # Without --export-less, we end up with some _odd_ imports in the stub file that aren't used!
- # +from airflow import AirflowException as AirflowException
- # +from airflow.hooks.base import BaseHook as BaseHook
- # We could avoid this if we had __all__ defined
- ["stubgen", "--export-less", *[os.fspath(path) for path in COMMON_SQL_ROOT.rglob("**/*.py")]],
+ ["stubgen", *[os.fspath(path) for path in COMMON_SQL_ROOT.rglob("**/*.py")]],
cwd=AIRFLOW_SOURCES_ROOT_PATH,
)
total_removals, total_additions = 0, 0
@@ -353,7 +348,7 @@ if __name__ == "__main__":
total_removals += _new_removals
total_additions += _new_additions
for target_path in COMMON_SQL_ROOT.rglob("*.pyi"):
- generated_path = OUT_DIR / target_path.relative_to(AIRFLOW_SOURCES_ROOT_PATH)
+ generated_path = OUT_DIR / target_path.relative_to(PROVIDERS_ROOT)
if not generated_path.exists():
console.print(
f"[red]The {target_path} file is missing in generated files:. "
diff --git a/scripts/in_container/run_provider_yaml_files_check.py b/scripts/in_container/run_provider_yaml_files_check.py
index 28ec9e0f02..a629c75d75 100755
--- a/scripts/in_container/run_provider_yaml_files_check.py
+++ b/scripts/in_container/run_provider_yaml_files_check.py
@@ -56,7 +56,7 @@ PROVIDER_ISSUE_TEMPLATE_PATH = ROOT_DIR.joinpath(
)
CORE_INTEGRATIONS = ["SQL", "Local"]
-errors: list[str] = []
+errors = []
console = Console(width=400, color_system="standard")
diff --git a/setup.cfg b/setup.cfg
index 00fdc06aee..657c2ded83 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -186,13 +186,6 @@ plugins =
dev.mypy.plugin.outputs
pretty = True
show_error_codes = True
-disable_error_code =
- # "By default the bodies of untyped functions are not checked, consider using --check-untyped-defs"
- annotation-unchecked
-
-[mypy-airflow.config_templates.default_webserver_config]
-# This file gets written to user installs, so lets not litter it with type comments
-disable_error_code = var-annotated
[mypy-airflow.migrations.*]
ignore_errors = True
diff --git a/setup.py b/setup.py
index 84591c390c..f9da876aec 100644
--- a/setup.py
+++ b/setup.py
@@ -338,7 +338,7 @@ mypy_dependencies = [
# TODO: upgrade to newer versions of MyPy continuously as they are released
# Make sure to upgrade the mypy version in update-common-sql-api-stubs in .pre-commit-config.yaml
# when you upgrade it here !!!!
- "mypy==0.991",
+ "mypy==0.971",
"types-boto",
"types-certifi",
"types-croniter",
diff --git a/tests/listeners/dag_listener.py b/tests/listeners/dag_listener.py
index 07f0638dd1..826316e6a6 100644
--- a/tests/listeners/dag_listener.py
+++ b/tests/listeners/dag_listener.py
@@ -26,9 +26,7 @@ if typing.TYPE_CHECKING:
from airflow.models.dagrun import DagRun
-running: list[DagRun] = []
-success: list[DagRun] = []
-failure: list[DagRun] = []
+running, success, failure = [], [], []
@hookimpl
diff --git a/tests/listeners/full_listener.py b/tests/listeners/full_listener.py
index da4f723853..32281c876f 100644
--- a/tests/listeners/full_listener.py
+++ b/tests/listeners/full_listener.py
@@ -17,14 +17,12 @@
# under the License.
from __future__ import annotations
-from typing import Any
-
from airflow.listeners import hookimpl
from airflow.utils.state import State
-started_component: Any = None
-stopped_component: Any = None
-state: list[Any] = []
+started_component = None
+stopped_component = None
+state = []
@hookimpl
diff --git a/tests/listeners/lifecycle_listener.py b/tests/listeners/lifecycle_listener.py
index 5fab1dc640..a626b6ae20 100644
--- a/tests/listeners/lifecycle_listener.py
+++ b/tests/listeners/lifecycle_listener.py
@@ -17,12 +17,10 @@
from __future__ import annotations
-from typing import Any
-
from airflow.listeners import hookimpl
-started_component: Any = None
-stopped_component: Any = None
+started_component = None
+stopped_component = None
@hookimpl
diff --git a/tests/listeners/partial_listener.py b/tests/listeners/partial_listener.py
index b4027e2875..2f539a3c3d 100644
--- a/tests/listeners/partial_listener.py
+++ b/tests/listeners/partial_listener.py
@@ -20,7 +20,7 @@ from __future__ import annotations
from airflow.listeners import hookimpl
from airflow.utils.state import State
-state: list[State] = []
+state = []
@hookimpl
diff --git a/tests/test_utils/timetables.py b/tests/test_utils/timetables.py
index f5a274e5f4..d246d76d3a 100644
--- a/tests/test_utils/timetables.py
+++ b/tests/test_utils/timetables.py
@@ -49,12 +49,3 @@ class CustomSerializationTimetable(Timetable):
@property
def summary(self):
return f"{type(self).__name__}({self.value!r})"
-
- def validate(self) -> None:
- pass
-
- def infer_manual_data_interval(self, *, run_after):
- raise NotImplementedError()
-
- def next_dagrun_info(self, *, last_automated_data_interval, restriction):
- raise NotImplementedError()
diff --git a/tests/www/views/test_views_connection.py b/tests/www/views/test_views_connection.py
index 714c87a8dc..9235298022 100644
--- a/tests/www/views/test_views_connection.py
+++ b/tests/www/views/test_views_connection.py
@@ -18,7 +18,6 @@
from __future__ import annotations
import json
-from typing import Any
from unittest import mock
from unittest.mock import PropertyMock
@@ -31,7 +30,7 @@ from airflow.www.extensions import init_views
from airflow.www.views import ConnectionFormWidget, ConnectionModelView
from tests.test_utils.www import _check_last_log, _check_last_log_masked_connection, check_content_in_response
-CONNECTION: dict[str, Any] = {
+CONNECTION = {
"conn_id": "test_conn",
"conn_type": "http",
"description": "description",
@@ -42,8 +41,13 @@ CONNECTION: dict[str, Any] = {
}
-def conn_with_extra() -> dict[str, Any]:
- return {**CONNECTION, "extra": '{"x_secret": "testsecret","y_secret": "test"}'}
+def conn_with_extra():
+ CONNECTION.update(
+ {
+ "extra": '{"x_secret": "testsecret","y_secret": "test"}',
+ }
+ )
+ return CONNECTION
@pytest.fixture(autouse=True)