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 2024/02/16 23:36:14 UTC
(airflow) branch main updated: Replace other Python 3.11 and 3.12 deprecations (#37478)
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 ef70594358 Replace other Python 3.11 and 3.12 deprecations (#37478)
ef70594358 is described below
commit ef70594358f5e5e3aa7c27de621869aa5d4b2d27
Author: Andrey Anshin <An...@taragol.is>
AuthorDate: Sat Feb 17 03:36:03 2024 +0400
Replace other Python 3.11 and 3.12 deprecations (#37478)
* Replace usage of deprecated typing classes (Python 3.12)
* Replace usage of locale.getdefaultlocale (Python 3.11)
---
airflow/cli/commands/info_command.py | 2 +-
airflow/exceptions.py | 3 ++-
airflow/models/expandinput.py | 3 ++-
pyproject.toml | 6 ++++++
4 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/airflow/cli/commands/info_command.py b/airflow/cli/commands/info_command.py
index 3d72e4641e..83c62f7188 100644
--- a/airflow/cli/commands/info_command.py
+++ b/airflow/cli/commands/info_command.py
@@ -259,7 +259,7 @@ class AirflowInfo:
operating_system = OperatingSystem.get_current()
arch = Architecture.get_current()
uname = platform.uname()
- _locale = locale.getdefaultlocale()
+ _locale = locale.getlocale()
python_location = self.anonymizer.process_path(sys.executable)
python_version = sys.version.replace("\n", " ")
diff --git a/airflow/exceptions.py b/airflow/exceptions.py
index 2ca75cbbf8..f747640c77 100644
--- a/airflow/exceptions.py
+++ b/airflow/exceptions.py
@@ -22,12 +22,13 @@ from __future__ import annotations
import warnings
from http import HTTPStatus
-from typing import TYPE_CHECKING, Any, NamedTuple, Sized
+from typing import TYPE_CHECKING, Any, NamedTuple
from airflow.utils.trigger_rule import TriggerRule
if TYPE_CHECKING:
import datetime
+ from collections.abc import Sized
from airflow.models import DAG, DagRun
diff --git a/airflow/models/expandinput.py b/airflow/models/expandinput.py
index 44f26a3483..a20280e5a1 100644
--- a/airflow/models/expandinput.py
+++ b/airflow/models/expandinput.py
@@ -20,7 +20,8 @@ from __future__ import annotations
import collections.abc
import functools
import operator
-from typing import TYPE_CHECKING, Any, Dict, Iterable, Mapping, NamedTuple, Sequence, Sized, Union
+from collections.abc import Sized
+from typing import TYPE_CHECKING, Any, Dict, Iterable, Mapping, NamedTuple, Sequence, Union
import attr
diff --git a/pyproject.toml b/pyproject.toml
index 9c5739bcab..8fe052e842 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1468,9 +1468,15 @@ banned-module-level-imports = ["numpy", "pandas"]
"airflow.AirflowException".msg = "Use airflow.exceptions.AirflowException instead."
"airflow.Dataset".msg = "Use airflow.datasets.Dataset instead."
"airflow.models.baseoperator.BaseOperatorLink".msg = "Use airflow.models.baseoperatorlink.BaseOperatorLink"
+# Deprecated in Python 3.11, Pending Removal in Python 3.15: https://github.com/python/cpython/issues/90817
+# Deprecation warning in Python 3.11 also recommends using locale.getencoding but it available in Python 3.11
+"locale.getdefaultlocale".msg = "Use locale.setlocale() and locale.getlocale() instead."
# Deprecated in Python 3.12: https://github.com/python/cpython/issues/103857
"datetime.datetime.utcnow".msg = "Use airflow.utils.timezone.utcnow or datetime.datetime.now(tz=datetime.timezone.utc)"
"datetime.datetime.utcfromtimestamp".msg = "Use airflow.utils.timezone.from_timestamp or datetime.datetime.fromtimestamp(tz=datetime.timezone.utc)"
+# Deprecated in Python 3.12: https://github.com/python/cpython/issues/94309
+"typing.Hashable".msg = "Use collections.abc.Hashable"
+"typing.Sized".msg = "Use collections.abc.Sized"
# Uses deprecated in Python 3.12 `datetime.datetime.utcfromtimestamp`
"pendulum.from_timestamp".msg = "Use airflow.utils.timezone.from_timestamp"