Skip to content

Commit

Permalink
D401 Support in Providers (simple) (#37258)
Browse files Browse the repository at this point in the history
  • Loading branch information
Taragolis authored Feb 8, 2024
1 parent 250f29f commit 08036e5
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 43 deletions.
4 changes: 2 additions & 2 deletions airflow/providers/apache/hive/hooks/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__(

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
"""Return connection widgets to add to Hive Client Wrapper connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import BooleanField, StringField
Expand All @@ -134,7 +134,7 @@ def get_connection_form_widgets(cls) -> dict[str, Any]:

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
"""Return custom UI field behaviour for Hive Client Wrapper connection."""
return {
"hidden_fields": ["extra"],
"relabeling": {},
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/apache/spark/hooks/spark_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SparkConnectHook(BaseHook, LoggingMixin):

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom field behaviour."""
"""Return custom UI field behaviour for Spark Connect connection."""
return {
"hidden_fields": [
"schema",
Expand All @@ -49,7 +49,7 @@ def get_ui_field_behaviour(cls) -> dict[str, Any]:

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
"""Return connection widgets to add to Spark Connect connection form."""
from flask_babel import lazy_gettext
from wtforms import BooleanField

Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/apache/spark/hooks/spark_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ class SparkSqlHook(BaseHook):

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom field behaviour."""
"""Return custom UI field behaviour for Spark SQL connection."""
return {
"hidden_fields": ["schema", "login", "password", "extra"],
"relabeling": {},
}

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
"""Return connection widgets to add to Spark SQL connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import StringField
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/apache/spark/hooks/spark_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ class SparkSubmitHook(BaseHook, LoggingMixin):

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom field behaviour."""
"""Return custom UI field behaviour for Spark connection."""
return {
"hidden_fields": ["schema", "login", "password", "extra"],
"relabeling": {},
}

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
"""Return connection widgets to add to Spark connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import StringField
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/atlassian/jira/hooks/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_conn(self) -> Jira:

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
"""Return connection widgets to add to Atlassian Jira Connection form."""
from flask_babel import lazy_gettext
from wtforms import BooleanField

Expand All @@ -95,7 +95,7 @@ def get_connection_form_widgets(cls) -> dict[str, Any]:

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
"""Return custom UI field behaviour for Atlassian Jira Connection."""
return {
"hidden_fields": ["schema", "extra"],
"relabeling": {},
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/discord/hooks/discord_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DiscordWebhookHook(HttpHook):

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
"""Return connection widgets to add to Discord connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import StringField
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/grpc/hooks/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class GrpcHook(BaseHook):

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
"""Return connection widgets to add to GRPC connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import StringField
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/jenkins/hooks/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class JenkinsHook(BaseHook):

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
"""Return connection widgets to add to Jenkins connection form."""
from flask_babel import lazy_gettext
from wtforms import BooleanField

Expand All @@ -47,7 +47,7 @@ def get_connection_form_widgets(cls) -> dict[str, Any]:

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
"""Return custom UI field behaviour for Jenkins connection."""
return {
"hidden_fields": ["schema", "extra"],
"relabeling": {},
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/microsoft/mssql/hooks/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_sqlalchemy_connection(
return engine.connect(**(connect_kwargs or {}))

def get_conn(self) -> pymssql.connect:
"""Returns a mssql connection object."""
"""Return ``pymssql`` connection object."""
conn = self.get_connection(self.mssql_conn_id) # type: ignore[attr-defined]

conn = pymssql.connect(
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/odbc/hooks/odbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def connect_kwargs(self) -> dict:
return merged_connect_kwargs

def get_conn(self) -> Connection:
"""Returns a pyodbc connection object."""
"""Return ``pyodbc`` connection object."""
conn = connect(self.odbc_connection_string, **self.connect_kwargs)
return conn

Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/opsgenie/hooks/opsgenie.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def delete_alert(

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
"""Return custom UI field behaviour for Opsgenie connection."""
return {
"hidden_fields": ["port", "schema", "login", "extra"],
"relabeling": {"password": "Opsgenie API Key"},
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/redis/hooks/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class RedisHook(BaseHook):

def __init__(self, redis_conn_id: str = default_conn_name) -> None:
"""
Prepares hook to connect to a Redis database.
Prepare hook to connect to a Redis database.
:param conn_id: the name of the connection that has the parameters
we need to connect to Redis.
Expand All @@ -61,7 +61,7 @@ def __init__(self, redis_conn_id: str = default_conn_name) -> None:
self.db = None

def get_conn(self):
"""Returns a Redis connection."""
"""Return a Redis connection."""
conn = self.get_connection(self.redis_conn_id)
self.host = conn.host
self.port = conn.port
Expand Down Expand Up @@ -111,15 +111,15 @@ def get_conn(self):

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
"""Return custom UI field behaviour for Redis connection."""
return {
"hidden_fields": ["schema", "extra"],
"relabeling": {},
}

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
"""Return connection widgets to add to Redis connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import BooleanField, IntegerField, StringField
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/sqlite/hooks/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, *args, **kwargs):
self._placeholder: str = "?"

def get_conn(self) -> sqlite3.dbapi2.Connection:
"""Returns a sqlite connection object."""
"""Return SQLite connection object."""
sqlalchemy_uri = self.get_uri()
# The sqlite3 connection does not use the sqlite scheme.
# See https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#uri-connections for details.
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/ssh/hooks/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class SSHHook(BaseHook):

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
"""Return custom UI field behaviour for SSH connection."""
return {
"hidden_fields": ["schema"],
"relabeling": {
Expand Down Expand Up @@ -283,7 +283,7 @@ def host_proxy(self) -> paramiko.ProxyCommand | None:
return paramiko.ProxyCommand(cmd) if cmd else None

def get_conn(self) -> paramiko.SSHClient:
"""Opens an SSH connection to the remote host."""
"""Establish an SSH connection to the remote host."""
self.log.debug("Creating SSH client for conn_id: %s", self.ssh_conn_id)
client = paramiko.SSHClient()

Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/tabular/hooks/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TabularHook(BaseHook):

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
"""Return custom UI field behaviour for Tabular connection."""
return {
"hidden_fields": ["schema", "port"],
"relabeling": {
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/yandex/hooks/yandex.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class YandexCloudBaseHook(BaseHook):

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
"""Return connection widgets to add to Yandex connection form."""
from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget, BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import PasswordField, StringField
Expand Down Expand Up @@ -107,7 +107,7 @@ def provider_user_agent(cls) -> str | None:

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Returns custom field behaviour."""
"""Return custom UI field behaviour for Yandex connection."""
return {
"hidden_fields": ["host", "schema", "login", "password", "port", "extra"],
"relabeling": {},
Expand Down
16 changes: 0 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1380,11 +1380,6 @@ combine-as-imports = true
"airflow/providers/amazon/aws/triggers/redshift_cluster.py" = ["D401"]
"airflow/providers/amazon/aws/triggers/redshift_data.py" = ["D401"]
"airflow/providers/amazon/aws/triggers/sagemaker.py" = ["D401"]
"airflow/providers/apache/hive/hooks/hive.py" = ["D401"]
"airflow/providers/apache/spark/hooks/spark_connect.py" = ["D401"]
"airflow/providers/apache/spark/hooks/spark_sql.py" = ["D401"]
"airflow/providers/apache/spark/hooks/spark_submit.py" = ["D401"]
"airflow/providers/atlassian/jira/hooks/jira.py" = ["D401"]
"airflow/providers/cncf/kubernetes/callbacks.py" = ["D401"]
"airflow/providers/cncf/kubernetes/operators/custom_object_launcher.py" = ["D401"]
"airflow/providers/cncf/kubernetes/operators/spark_kubernetes.py" = ["D401"]
Expand All @@ -1394,7 +1389,6 @@ combine-as-imports = true
"airflow/providers/common/io/xcom/backend.py" = ["D401"]
"airflow/providers/databricks/hooks/databricks.py" = ["D401"]
"airflow/providers/databricks/operators/databricks.py" = ["D401"]
"airflow/providers/discord/hooks/discord_webhook.py" = ["D401"]
"airflow/providers/fab/auth_manager/decorators/auth.py" = ["D401"]
"airflow/providers/fab/auth_manager/fab_auth_manager.py" = ["D401"]
"airflow/providers/fab/auth_manager/security_manager/override.py" = ["D401"]
Expand Down Expand Up @@ -1525,13 +1519,11 @@ combine-as-imports = true
"airflow/providers/google/suite/hooks/calendar.py" = ["D401"]
"airflow/providers/google/suite/hooks/drive.py" = ["D401"]
"airflow/providers/google/suite/hooks/sheets.py" = ["D401"]
"airflow/providers/grpc/hooks/grpc.py" = ["D401"]
"airflow/providers/hashicorp/_internal_client/vault_client.py" = ["D401"]
"airflow/providers/hashicorp/hooks/vault.py" = ["D401"]
"airflow/providers/http/operators/http.py" = ["D401"]
"airflow/providers/http/triggers/http.py" = ["D401"]
"airflow/providers/imap/hooks/imap.py" = ["D401"]
"airflow/providers/jenkins/hooks/jenkins.py" = ["D401"]
"airflow/providers/microsoft/azure/hooks/adx.py" = ["D401"]
"airflow/providers/microsoft/azure/hooks/asb.py" = ["D401"]
"airflow/providers/microsoft/azure/hooks/base_azure.py" = ["D401"]
Expand All @@ -1555,20 +1547,17 @@ combine-as-imports = true
"airflow/providers/microsoft/azure/transfers/sftp_to_wasb.py" = ["D401"]
"airflow/providers/microsoft/azure/triggers/data_factory.py" = ["D401"]
"airflow/providers/microsoft/azure/triggers/wasb.py" = ["D401"]
"airflow/providers/microsoft/mssql/hooks/mssql.py" = ["D401"]
"airflow/providers/microsoft/psrp/hooks/psrp.py" = ["D401"]
"airflow/providers/mongo/hooks/mongo.py" = ["D401"]
"airflow/providers/mysql/hooks/mysql.py" = ["D401"]
"airflow/providers/mysql/transfers/s3_to_mysql.py" = ["D401"]
"airflow/providers/neo4j/hooks/neo4j.py" = ["D401"]
"airflow/providers/odbc/hooks/odbc.py" = ["D401"]
"airflow/providers/openfaas/hooks/openfaas.py" = ["D401"]
"airflow/providers/openlineage/plugins/adapter.py" = ["D401"]
"airflow/providers/openlineage/sqlparser.py" = ["D401"]
"airflow/providers/openlineage/utils/sql.py" = ["D401"]
"airflow/providers/opensearch/hooks/opensearch.py" = ["D401"]
"airflow/providers/opensearch/operators/opensearch.py" = ["D401"]
"airflow/providers/opsgenie/hooks/opsgenie.py" = ["D401"]
"airflow/providers/oracle/hooks/oracle.py" = ["D401"]
"airflow/providers/pagerduty/hooks/pagerduty.py" = ["D401"]
"airflow/providers/pagerduty/hooks/pagerduty_events.py" = ["D401"]
Expand All @@ -1577,7 +1566,6 @@ combine-as-imports = true
"airflow/providers/postgres/hooks/postgres.py" = ["D401"]
"airflow/providers/presto/hooks/presto.py" = ["D401"]
"airflow/providers/qdrant/hooks/qdrant.py" = ["D401"]
"airflow/providers/redis/hooks/redis.py" = ["D401"]
"airflow/providers/salesforce/hooks/salesforce.py" = ["D401"]
"airflow/providers/salesforce/operators/bulk.py" = ["D401"]
"airflow/providers/salesforce/operators/salesforce_apex_rest.py" = ["D401"]
Expand All @@ -1599,16 +1587,12 @@ combine-as-imports = true
"airflow/providers/snowflake/transfers/copy_into_snowflake.py" = ["D401"]
"airflow/providers/snowflake/triggers/snowflake_trigger.py" = ["D401"]
"airflow/providers/snowflake/utils/sql_api_generate_jwt.py" = ["D401"]
"airflow/providers/sqlite/hooks/sqlite.py" = ["D401"]
"airflow/providers/ssh/hooks/ssh.py" = ["D401"]
"airflow/providers/tableau/hooks/tableau.py" = ["D401"]
"airflow/providers/tableau/operators/tableau.py" = ["D401"]
"airflow/providers/tabular/hooks/tabular.py" = ["D401"]
"airflow/providers/telegram/hooks/telegram.py" = ["D401"]
"airflow/providers/telegram/operators/telegram.py" = ["D401"]
"airflow/providers/trino/hooks/trino.py" = ["D401"]
"airflow/providers/weaviate/hooks/weaviate.py" = ["D401"]
"airflow/providers/yandex/hooks/yandex.py" = ["D401"]


[tool.ruff.lint.flake8-tidy-imports]
Expand Down

0 comments on commit 08036e5

Please sign in to comment.