Skip to content

Commit

Permalink
Remove remaining deprecated classes and replace them with PEP562 (#26167
Browse files Browse the repository at this point in the history
)

This is a follow-up after #26513 - removal of all remaining
deprecated classes and replace them with PEP-562 dynamic attribute
loading.
  • Loading branch information
potiuk authored Sep 7, 2022
1 parent 666df95 commit 63562d7
Show file tree
Hide file tree
Showing 93 changed files with 357 additions and 3,217 deletions.
3 changes: 2 additions & 1 deletion airflow/contrib/hooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
"""This package is deprecated. Please use `airflow.hooks` or `airflow.providers.*.hooks`."""
import warnings

from airflow.exceptions import RemovedInAirflow3Warning
from airflow.utils.deprecation_tools import add_deprecated_classes

warnings.warn(
"This package is deprecated. Please use `airflow.hooks` or `airflow.providers.*.hooks`.",
DeprecationWarning,
RemovedInAirflow3Warning,
stacklevel=2,
)

Expand Down
3 changes: 2 additions & 1 deletion airflow/contrib/operators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
"""This package is deprecated. Please use `airflow.operators` or `airflow.providers.*.operators`."""
import warnings

from airflow.exceptions import RemovedInAirflow3Warning
from airflow.utils.deprecation_tools import add_deprecated_classes

warnings.warn(
"This package is deprecated. Please use `airflow.operators` or `airflow.providers.*.operators`.",
DeprecationWarning,
RemovedInAirflow3Warning,
stacklevel=2,
)

Expand Down
5 changes: 4 additions & 1 deletion airflow/contrib/secrets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
"""This package is deprecated. Please use `airflow.secrets` or `airflow.providers.*.secrets`."""
import warnings

from airflow.exceptions import RemovedInAirflow3Warning
from airflow.utils.deprecation_tools import add_deprecated_classes

warnings.warn(
"This module is deprecated. Please use airflow.providers.*.secrets.", DeprecationWarning, stacklevel=2
"This module is deprecated. Please use airflow.providers.*.secrets.",
RemovedInAirflow3Warning,
stacklevel=2
)

__deprecated_classes = {
Expand Down
3 changes: 2 additions & 1 deletion airflow/contrib/sensors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

import warnings

from airflow.exceptions import RemovedInAirflow3Warning
from airflow.utils.deprecation_tools import add_deprecated_classes

warnings.warn(
"This package is deprecated. Please use `airflow.sensors` or `airflow.providers.*.sensors`.",
DeprecationWarning,
RemovedInAirflow3Warning,
stacklevel=2,
)

Expand Down
3 changes: 2 additions & 1 deletion airflow/contrib/task_runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
"""This package is deprecated. Please use `airflow.task.task_runner`."""
import warnings

from airflow.exceptions import RemovedInAirflow3Warning
from airflow.utils.deprecation_tools import add_deprecated_classes

warnings.warn(
"This module is deprecated. Please use airflow.task.task_runner.", DeprecationWarning, stacklevel=2
"This module is deprecated. Please use airflow.task.task_runner.", RemovedInAirflow3Warning, stacklevel=2
)

__deprecated_classes = {
Expand Down
7 changes: 6 additions & 1 deletion airflow/contrib/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@

import warnings

from airflow.exceptions import RemovedInAirflow3Warning
from airflow.utils.deprecation_tools import add_deprecated_classes

warnings.warn("This module is deprecated. Please use `airflow.utils`.", DeprecationWarning, stacklevel=2)
warnings.warn(
"This module is deprecated. Please use `airflow.utils`.",
RemovedInAirflow3Warning,
stacklevel=2
)

__deprecated_classes = {
'gcp_field_sanitizer': {
Expand Down
31 changes: 0 additions & 31 deletions airflow/hooks/S3_hook.py

This file was deleted.

74 changes: 74 additions & 0 deletions airflow/hooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,78 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# fmt: off
"""Hooks."""
from airflow.utils.deprecation_tools import add_deprecated_classes

__deprecated_classes = {
'S3_hook': {
'S3Hook': 'airflow.providers.amazon.aws.hooks.s3.S3Hook',
'provide_bucket_name': 'airflow.providers.amazon.aws.hooks.s3.provide_bucket_name',
},
'base_hook': {
'BaseHook': 'airflow.hooks.base.BaseHook',
},
'dbapi_hook': {
'DbApiHook': 'airflow.providers.common.sql.hooks.sql.DbApiHook',
},
'docker_hook': {
'DockerHook': 'airflow.providers.docker.hooks.docker.DockerHook',
},
'druid_hook': {
'DruidDbApiHook': 'airflow.providers.apache.druid.hooks.druid.DruidDbApiHook',
'DruidHook': 'airflow.providers.apache.druid.hooks.druid.DruidHook',
},
'hdfs_hook': {
'HDFSHook': 'airflow.providers.apache.hdfs.hooks.hdfs.HDFSHook',
'HDFSHookException': 'airflow.providers.apache.hdfs.hooks.hdfs.HDFSHookException',
},
'hive_hooks': {
'HIVE_QUEUE_PRIORITIES': 'airflow.providers.apache.hive.hooks.hive.HIVE_QUEUE_PRIORITIES',
'HiveCliHook': 'airflow.providers.apache.hive.hooks.hive.HiveCliHook',
'HiveMetastoreHook': 'airflow.providers.apache.hive.hooks.hive.HiveMetastoreHook',
'HiveServer2Hook': 'airflow.providers.apache.hive.hooks.hive.HiveServer2Hook',
},
'http_hook': {
'HttpHook': 'airflow.providers.http.hooks.http.HttpHook',
},
'jdbc_hook': {
'JdbcHook': 'airflow.providers.jdbc.hooks.jdbc.JdbcHook',
'jaydebeapi': 'airflow.providers.jdbc.hooks.jdbc.jaydebeapi',
},
'mssql_hook': {
'MsSqlHook': 'airflow.providers.microsoft.mssql.hooks.mssql.MsSqlHook',
},
'mysql_hook': {
'MySqlHook': 'airflow.providers.mysql.hooks.mysql.MySqlHook',
},
'oracle_hook': {
'OracleHook': 'airflow.providers.oracle.hooks.oracle.OracleHook',
},
'pig_hook': {
'PigCliHook': 'airflow.providers.apache.pig.hooks.pig.PigCliHook',
},
'postgres_hook': {
'PostgresHook': 'airflow.providers.postgres.hooks.postgres.PostgresHook',
},
'presto_hook': {
'PrestoHook': 'airflow.providers.presto.hooks.presto.PrestoHook',
},
'samba_hook': {
'SambaHook': 'airflow.providers.samba.hooks.samba.SambaHook',
},
'slack_hook': {
'SlackHook': 'airflow.providers.slack.hooks.slack.SlackHook',
},
'sqlite_hook': {
'SqliteHook': 'airflow.providers.sqlite.hooks.sqlite.SqliteHook',
},
'webhdfs_hook': {
'WebHDFSHook': 'airflow.providers.apache.hdfs.hooks.webhdfs.WebHDFSHook',
},
'zendesk_hook': {
'ZendeskHook': 'airflow.providers.zendesk.hooks.zendesk.ZendeskHook',
},
}

add_deprecated_classes(__deprecated_classes, __name__)
29 changes: 0 additions & 29 deletions airflow/hooks/base_hook.py

This file was deleted.

29 changes: 0 additions & 29 deletions airflow/hooks/dbapi_hook.py

This file was deleted.

29 changes: 0 additions & 29 deletions airflow/hooks/docker_hook.py

This file was deleted.

29 changes: 0 additions & 29 deletions airflow/hooks/druid_hook.py

This file was deleted.

29 changes: 0 additions & 29 deletions airflow/hooks/hdfs_hook.py

This file was deleted.

34 changes: 0 additions & 34 deletions airflow/hooks/hive_hooks.py

This file was deleted.

Loading

0 comments on commit 63562d7

Please sign in to comment.