Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove outdated compat imports/code from providers #28507

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions airflow/providers/amazon/aws/secrets/secrets_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from urllib.parse import unquote

from airflow.compat.functools import cached_property
from airflow.providers.amazon.aws.utils import get_airflow_version, trim_none_values
from airflow.providers.amazon.aws.utils import trim_none_values
from airflow.secrets import BaseSecretsBackend
from airflow.utils.log.logging_mixin import LoggingMixin

Expand Down Expand Up @@ -254,13 +254,12 @@ def get_conn_uri(self, conn_id: str) -> str | None:
:param conn_id: the connection id
:return: deserialized Connection
"""
if get_airflow_version() >= (2, 3):
warnings.warn(
f"Method `{self.__class__.__name__}.get_conn_uri` is deprecated and will be removed "
"in a future release. Please use method `get_conn_value` instead.",
DeprecationWarning,
stacklevel=2,
)
warnings.warn(
f"Method `{self.__class__.__name__}.get_conn_uri` is deprecated and will be removed "
"in a future release. Please use method `get_conn_value` instead.",
DeprecationWarning,
stacklevel=2,
)
return self.get_conn_value(conn_id)

def get_variable(self, key: str) -> str | None:
Expand Down
29 changes: 0 additions & 29 deletions airflow/providers/cncf/kubernetes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,3 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from __future__ import annotations

import sys

if sys.version_info < (3, 7):
# This is needed because the Python Kubernetes client >= 12.0 contains a logging object, meaning that
# v1.Pod et al. are not pickleable on Python 3.6.

# Python 3.7 added this via https://bugs.python.org/issue30520 in 2017 -- but Python 3.6 doesn't have this
# method.

# This is duplicated/backported from airflow.logging_config in 2.2, but by having it here as well it means
# that we can update the version used in this provider and have it work for older versions
import copyreg
import logging

def _reduce_Logger(logger):
if logging.getLogger(logger.name) is not logger:
import pickle

raise pickle.PicklingError("logger cannot be pickled")
return logging.getLogger, (logger.name,)

def _reduce_RootLogger(logger):
return logging.getLogger, ()

if logging.Logger not in copyreg.dispatch_table:
copyreg.pickle(logging.Logger, _reduce_Logger)
copyreg.pickle(logging.RootLogger, _reduce_RootLogger)
7 changes: 1 addition & 6 deletions airflow/providers/microsoft/winrm/hooks/winrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@

from airflow.exceptions import AirflowException
from airflow.hooks.base import BaseHook

try:
from airflow.utils.platform import getuser
except ImportError:
from getpass import getuser # type: ignore[misc]

from airflow.utils.platform import getuser

# TODO: Fixme please - I have too complex implementation

Expand Down
10 changes: 1 addition & 9 deletions airflow/providers/presto/hooks/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@
from airflow.configuration import conf
from airflow.models import Connection
from airflow.providers.common.sql.hooks.sql import DbApiHook
from airflow.utils.operator_helpers import AIRFLOW_VAR_NAME_FORMAT_MAPPING

try:
from airflow.utils.operator_helpers import DEFAULT_FORMAT_PREFIX
except ImportError:
# This is from airflow.utils.operator_helpers,
# For the sake of provider backward compatibility, this is hardcoded if import fails
# https://github.com/apache/airflow/pull/22416#issuecomment-1075531290
DEFAULT_FORMAT_PREFIX = "airflow.ctx."
from airflow.utils.operator_helpers import AIRFLOW_VAR_NAME_FORMAT_MAPPING, DEFAULT_FORMAT_PREFIX


def generate_presto_client_info() -> str:
Expand Down
6 changes: 1 addition & 5 deletions airflow/providers/ssh/hooks/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@
from airflow.compat.functools import cached_property
from airflow.exceptions import AirflowException
from airflow.hooks.base import BaseHook

try:
from airflow.utils.platform import getuser
except ImportError:
from getpass import getuser # type: ignore[misc]
from airflow.utils.platform import getuser

TIMEOUT_DEFAULT = 10

Expand Down
10 changes: 1 addition & 9 deletions airflow/providers/trino/hooks/trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@
from airflow.configuration import conf
from airflow.models import Connection
from airflow.providers.common.sql.hooks.sql import DbApiHook
from airflow.utils.operator_helpers import AIRFLOW_VAR_NAME_FORMAT_MAPPING

try:
from airflow.utils.operator_helpers import DEFAULT_FORMAT_PREFIX
except ImportError:
# This is from airflow.utils.operator_helpers,
# For the sake of provider backward compatibility, this is hardcoded if import fails
# https://github.com/apache/airflow/pull/22416#issuecomment-1075531290
DEFAULT_FORMAT_PREFIX = "airflow.ctx."
from airflow.utils.operator_helpers import AIRFLOW_VAR_NAME_FORMAT_MAPPING, DEFAULT_FORMAT_PREFIX


def generate_trino_client_info() -> str:
Expand Down