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 remaining deprecated classes and replace them with PEP562 #26167

Merged
merged 1 commit into from
Sep 7, 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
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