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 cbde23e6bc Upgrade to MyPy 1.2.0 (#30687)
cbde23e6bc is described below
commit cbde23e6bcdd2235f8becb0abf858a7ffcf6e91c
Author: Jarek Potiuk <[email protected]>
AuthorDate: Mon Apr 17 22:38:55 2023 +0200
Upgrade to MyPy 1.2.0 (#30687)
Upgrading to latest (released a week ago) MyPy in the hopes it
will fix some more problem with attrs after upgrading new packages,
but it seems that even the latest MyPy does not know about the
new typing changes introduced in attrs (traditionally mypy has
attrs plugin that injects appropriate typing but apparently it
needs to catch up with those changes.
---
.pre-commit-config.yaml | 2 +-
airflow/decorators/task_group.py | 6 ++++--
airflow/providers/openlineage/utils/utils.py | 3 ++-
airflow/serialization/pydantic/taskinstance.py | 2 +-
airflow/serialization/serde.py | 2 +-
setup.py | 2 +-
6 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index fa7a7fd51a..4a152a6c1d 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==1.0.0',
'black==22.12.0', 'jinja2']
+ additional_dependencies: ['rich>=12.4.4', 'mypy==1.2.0',
'black==22.12.0', 'jinja2']
pass_filenames: false
require_serial: true
- id: update-black-version
diff --git a/airflow/decorators/task_group.py b/airflow/decorators/task_group.py
index 2aa714be3b..f0d510193c 100644
--- a/airflow/decorators/task_group.py
+++ b/airflow/decorators/task_group.py
@@ -114,13 +114,15 @@ class _TaskGroupFactory(ExpandableFactory,
Generic[FParams, FReturn]):
return task_group
def override(self, **kwargs: Any) -> _TaskGroupFactory[FParams, FReturn]:
- return attr.evolve(self, tg_kwargs={**self.tg_kwargs, **kwargs})
+ # TODO: fixme when mypy gets compatible with new attrs
+ return attr.evolve(self, tg_kwargs={**self.tg_kwargs, **kwargs}) #
type: ignore[arg-type]
def partial(self, **kwargs: Any) -> _TaskGroupFactory[FParams, FReturn]:
self._validate_arg_names("partial", kwargs)
prevent_duplicates(self.partial_kwargs, kwargs, fail_reason="duplicate
partial")
kwargs.update(self.partial_kwargs)
- return attr.evolve(self, partial_kwargs=kwargs)
+ # TODO: fixme when mypy gets compatible with new attrs
+ return attr.evolve(self, partial_kwargs=kwargs) # type:
ignore[arg-type]
def expand(self, **kwargs: OperatorExpandArgument) -> DAGNode:
if not kwargs:
diff --git a/airflow/providers/openlineage/utils/utils.py
b/airflow/providers/openlineage/utils/utils.py
index 5ad3eb4c4c..a95c0edb32 100644
--- a/airflow/providers/openlineage/utils/utils.py
+++ b/airflow/providers/openlineage/utils/utils.py
@@ -342,7 +342,8 @@ class OpenLineageRedactor(SecretsMasker):
if name and should_hide_value_for_key(name):
return self._redact_all(item, depth, max_depth)
if attrs.has(type(item)):
- for dict_key, subval in attrs.asdict(item,
recurse=False).items():
+ # TODO: fixme when mypy gets compatible with new attrs
+ for dict_key, subval in attrs.asdict(item,
recurse=False).items(): # type: ignore[arg-type]
if _is_name_redactable(dict_key, item):
setattr(
item,
diff --git a/airflow/serialization/pydantic/taskinstance.py
b/airflow/serialization/pydantic/taskinstance.py
index 6398541d0b..9c87186873 100644
--- a/airflow/serialization/pydantic/taskinstance.py
+++ b/airflow/serialization/pydantic/taskinstance.py
@@ -111,4 +111,4 @@ class TaskInstancePydantic(BaseModelPydantic):
:return: Pydantic serialized version of DaGrun
"""
- return DagRunPydantic()
+ raise NotImplementedError()
diff --git a/airflow/serialization/serde.py b/airflow/serialization/serde.py
index 3429c75f86..5b19593984 100644
--- a/airflow/serialization/serde.py
+++ b/airflow/serialization/serde.py
@@ -157,7 +157,7 @@ def serialize(o: object, depth: int = 0) -> U | None:
# dataclasses
if dataclasses.is_dataclass(cls):
# fixme: unfortunately using asdict with nested dataclasses it looses
information
- data = dataclasses.asdict(o)
+ data = dataclasses.asdict(o) # type: ignore[call-overload]
dct[DATA] = serialize(data, depth + 1)
return dct
diff --git a/setup.py b/setup.py
index 1404aba062..d6e540cc98 100644
--- a/setup.py
+++ b/setup.py
@@ -332,7 +332,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==1.0.0",
+ "mypy==1.2.0",
"types-boto",
"types-certifi",
"types-croniter",