You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by hu...@apache.org on 2024/02/10 22:29:13 UTC

(airflow) branch main updated: Follow D401 style in openlineage, slack, and tableau providers (#37312)

This is an automated email from the ASF dual-hosted git repository.

husseinawala 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 326f9789cd Follow D401 style in openlineage, slack, and tableau providers (#37312)
326f9789cd is described below

commit 326f9789cd0b255956be0b547f0463da44e6439f
Author: Jennifer Melot <jt...@gmail.com>
AuthorDate: Sat Feb 10 17:29:07 2024 -0500

    Follow D401 style in openlineage, slack, and tableau providers (#37312)
    
    * Follow D401 style in openlineage provider
    
    * Follow D401 style in slack and tableau providers
---
 airflow/providers/openlineage/plugins/adapter.py |  6 +++---
 airflow/providers/openlineage/sqlparser.py       |  8 ++++----
 airflow/providers/openlineage/utils/sql.py       |  4 ++--
 airflow/providers/slack/hooks/slack.py           | 10 +++++-----
 airflow/providers/slack/hooks/slack_webhook.py   | 12 ++++++------
 airflow/providers/slack/operators/slack.py       |  4 ++--
 airflow/providers/tableau/hooks/tableau.py       |  5 ++++-
 airflow/providers/tableau/operators/tableau.py   |  2 +-
 pyproject.toml                                   |  8 --------
 9 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/airflow/providers/openlineage/plugins/adapter.py b/airflow/providers/openlineage/plugins/adapter.py
index 6f16b01706..e2ee8a2695 100644
--- a/airflow/providers/openlineage/plugins/adapter.py
+++ b/airflow/providers/openlineage/plugins/adapter.py
@@ -138,7 +138,7 @@ class OpenLineageAdapter(LoggingMixin):
         run_facets: dict[str, BaseFacet] | None = None,  # Custom run facets
     ):
         """
-        Emits openlineage event of type START.
+        Emit openlineage event of type START.
 
         :param run_id: globally unique identifier of task in dag run
         :param job_name: globally unique identifier of task in dag
@@ -202,7 +202,7 @@ class OpenLineageAdapter(LoggingMixin):
         task: OperatorLineage,
     ):
         """
-        Emits openlineage event of type COMPLETE.
+        Emit openlineage event of type COMPLETE.
 
         :param run_id: globally unique identifier of task in dag run
         :param job_name: globally unique identifier of task between dags
@@ -239,7 +239,7 @@ class OpenLineageAdapter(LoggingMixin):
         task: OperatorLineage,
     ):
         """
-        Emits openlineage event of type FAIL.
+        Emit openlineage event of type FAIL.
 
         :param run_id: globally unique identifier of task in dag run
         :param job_name: globally unique identifier of task between dags
diff --git a/airflow/providers/openlineage/sqlparser.py b/airflow/providers/openlineage/sqlparser.py
index d54c19dbc8..c27dedc53c 100644
--- a/airflow/providers/openlineage/sqlparser.py
+++ b/airflow/providers/openlineage/sqlparser.py
@@ -205,7 +205,7 @@ class SQLParser:
         database: str | None = None,
         sqlalchemy_engine: Engine | None = None,
     ) -> OperatorLineage:
-        """Parses SQL statement(s) and generates OpenLineage metadata.
+        """Parse SQL statement(s) and generate OpenLineage metadata.
 
         Generated OpenLineage metadata contains:
 
@@ -271,7 +271,7 @@ class SQLParser:
 
     @classmethod
     def normalize_sql(cls, sql: list[str] | str) -> str:
-        """Makes sure to return a semicolon-separated SQL statements."""
+        """Make sure to return a semicolon-separated SQL statement."""
         return ";\n".join(stmt.rstrip(" ;\r\n") for stmt in cls.split_sql_string(sql))
 
     @classmethod
@@ -309,7 +309,7 @@ class SQLParser:
         database: str | None = None,
         sqlalchemy_engine: Engine | None = None,
     ) -> str:
-        """Creates SELECT statement to query information schema table."""
+        """Create SELECT statement to query information schema table."""
         tables_hierarchy = cls._get_tables_hierarchy(
             tables,
             normalize_name=normalize_name,
@@ -333,7 +333,7 @@ class SQLParser:
         is_cross_db: bool = False,
     ) -> TablesHierarchy:
         """
-        Creates a hierarchy of database -> schema -> table name.
+        Create a hierarchy of database -> schema -> table name.
 
         This helps to create simpler information schema query grouped by
         database and schema.
diff --git a/airflow/providers/openlineage/utils/sql.py b/airflow/providers/openlineage/utils/sql.py
index da08fa68d4..f959745b93 100644
--- a/airflow/providers/openlineage/utils/sql.py
+++ b/airflow/providers/openlineage/utils/sql.py
@@ -148,7 +148,7 @@ def create_information_schema_query(
     use_flat_cross_db_query: bool = False,
     sqlalchemy_engine: Engine | None = None,
 ) -> str:
-    """Creates query for getting table schemas from information schema."""
+    """Create query for getting table schemas from information schema."""
     metadata = MetaData(sqlalchemy_engine)
     select_statements = []
     # Don't iterate over tables hierarchy, just pass it to query single information schema table
@@ -201,7 +201,7 @@ def create_filter_clauses(
     uppercase_names: bool = False,
 ) -> ClauseElement:
     """
-    Creates comprehensive filter clauses for all tables in one database.
+    Create comprehensive filter clauses for all tables in one database.
 
     :param mapping: a nested dictionary of database, schema names and list of tables in each
     :param information_schema_table: `sqlalchemy.Table` instance used to construct clauses
diff --git a/airflow/providers/slack/hooks/slack.py b/airflow/providers/slack/hooks/slack.py
index adbfd0ab88..f046a9c5fc 100644
--- a/airflow/providers/slack/hooks/slack.py
+++ b/airflow/providers/slack/hooks/slack.py
@@ -169,7 +169,7 @@ class SlackHook(BaseHook):
 
     def call(self, api_method: str, **kwargs) -> SlackResponse:
         """
-        Calls Slack WebClient `WebClient.api_call` with given arguments.
+        Call Slack WebClient `WebClient.api_call` with given arguments.
 
         :param api_method: The target Slack API method. e.g. 'chat.postMessage'. Required.
         :param http_verb: HTTP Verb. Optional (defaults to 'POST')
@@ -244,7 +244,7 @@ class SlackHook(BaseHook):
         initial_comment: str | None = None,
     ) -> SlackResponse:
         """
-        Sends one or more files to a Slack channel using the Slack SDK Client method `files_upload_v2`.
+        Send one or more files to a Slack channel using the Slack SDK Client method `files_upload_v2`.
 
         :param channel_id: The ID of the channel to send the file to.
             If omitting this parameter, then file will send to workspace.
@@ -329,7 +329,7 @@ class SlackHook(BaseHook):
 
     def get_channel_id(self, channel_name: str) -> str:
         """
-        Retrieves a Slack channel id by a channel name.
+        Retrieve a Slack channel id by a channel name.
 
         It continuously iterates over all Slack channels (public and private)
         until it finds the desired channel name in addition cache results for further usage.
@@ -383,7 +383,7 @@ class SlackHook(BaseHook):
 
     @classmethod
     def get_connection_form_widgets(cls) -> dict[str, Any]:
-        """Returns dictionary of widgets to be added for the hook to handle extra values."""
+        """Return dictionary of widgets to be added for the hook to handle extra values."""
         from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
         from flask_babel import lazy_gettext
         from wtforms import IntegerField, StringField
@@ -411,7 +411,7 @@ class SlackHook(BaseHook):
 
     @classmethod
     def get_ui_field_behaviour(cls) -> dict[str, Any]:
-        """Returns custom field behaviour."""
+        """Return custom field behaviour."""
         return {
             "hidden_fields": ["login", "port", "host", "schema", "extra"],
             "relabeling": {
diff --git a/airflow/providers/slack/hooks/slack_webhook.py b/airflow/providers/slack/hooks/slack_webhook.py
index fcf25e44aa..9eb376227c 100644
--- a/airflow/providers/slack/hooks/slack_webhook.py
+++ b/airflow/providers/slack/hooks/slack_webhook.py
@@ -35,7 +35,7 @@ LEGACY_INTEGRATION_PARAMS = ("channel", "username", "icon_emoji", "icon_url")
 
 
 def check_webhook_response(func: Callable) -> Callable:
-    """Function decorator that check WebhookResponse and raise an error if status code != 200."""
+    """Check WebhookResponse and raise an error if status code != 200."""
 
     @wraps(func)
     def wrapper(*args, **kwargs) -> Callable:
@@ -175,7 +175,7 @@ class SlackWebhookHook(BaseHook):
     @check_webhook_response
     def send_dict(self, body: dict[str, Any] | str, *, headers: dict[str, str] | None = None):
         """
-        Performs a Slack Incoming Webhook request with given JSON data block.
+        Perform a Slack Incoming Webhook request with given JSON data block.
 
         :param body: JSON data structure, expected dict or JSON-string.
         :param headers: Request headers for this request.
@@ -220,7 +220,7 @@ class SlackWebhookHook(BaseHook):
         **kwargs,
     ):
         """
-        Performs a Slack Incoming Webhook request with given arguments.
+        Perform a Slack Incoming Webhook request with given arguments.
 
         :param text: The text message
             (even when having blocks, setting this as well is recommended as it works as fallback).
@@ -257,7 +257,7 @@ class SlackWebhookHook(BaseHook):
         headers: dict[str, str] | None = None,
     ):
         """
-        Performs a Slack Incoming Webhook request with given text.
+        Perform a Slack Incoming Webhook request with given text.
 
         :param text: The text message.
         :param unfurl_links: Option to indicate whether text url should unfurl.
@@ -268,7 +268,7 @@ class SlackWebhookHook(BaseHook):
 
     @classmethod
     def get_connection_form_widgets(cls) -> dict[str, Any]:
-        """Returns dictionary of widgets to be added for the hook to handle extra values."""
+        """Return dictionary of widgets to be added for the hook to handle extra values."""
         from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
         from flask_babel import lazy_gettext
         from wtforms import IntegerField, StringField
@@ -291,7 +291,7 @@ class SlackWebhookHook(BaseHook):
 
     @classmethod
     def get_ui_field_behaviour(cls) -> dict[str, Any]:
-        """Returns custom field behaviour."""
+        """Return custom field behaviour."""
         return {
             "hidden_fields": ["login", "port", "extra"],
             "relabeling": {
diff --git a/airflow/providers/slack/operators/slack.py b/airflow/providers/slack/operators/slack.py
index 838786f332..2fdafe3689 100644
--- a/airflow/providers/slack/operators/slack.py
+++ b/airflow/providers/slack/operators/slack.py
@@ -88,9 +88,9 @@ class SlackAPIOperator(BaseOperator):
         )
 
     def construct_api_call_params(self) -> Any:
-        """API call parameters used by the execute function.
+        """Construct API call parameters used by the execute function.
 
-        Allows templating on the source fields of the ``api_call_params`` dict
+        Allow templating on the source fields of the ``api_call_params`` dict
         before construction.
 
         Child classes should override this. Each SlackAPIOperator child class is
diff --git a/airflow/providers/tableau/hooks/tableau.py b/airflow/providers/tableau/hooks/tableau.py
index 723eb0c02f..e679133a15 100644
--- a/airflow/providers/tableau/hooks/tableau.py
+++ b/airflow/providers/tableau/hooks/tableau.py
@@ -129,7 +129,10 @@ class TableauHook(BaseHook):
         category=AirflowProviderDeprecationWarning,
     )
     def _auth_via_token(self) -> Auth.contextmgr:
-        """The method is deprecated. Please, use the authentication via password instead."""
+        """Authenticate via personal access token.
+
+        This method is deprecated. Please, use the authentication via password instead.
+        """
         tableau_auth = PersonalAccessTokenAuth(
             token_name=self.conn.extra_dejson["token_name"],
             personal_access_token=self.conn.extra_dejson["personal_access_token"],
diff --git a/airflow/providers/tableau/operators/tableau.py b/airflow/providers/tableau/operators/tableau.py
index 5eb8a92a3e..e4a447a654 100644
--- a/airflow/providers/tableau/operators/tableau.py
+++ b/airflow/providers/tableau/operators/tableau.py
@@ -94,7 +94,7 @@ class TableauOperator(BaseOperator):
 
     def execute(self, context: Context) -> str:
         """
-        Executes the Tableau API resource and pushes the job id or downloaded file URI to xcom.
+        Execute the Tableau API resource and push the job id or downloaded file URI to xcom.
 
         :param context: The task context during execution.
         :return: the id of the job that executes the extract refresh or downloaded file URI.
diff --git a/pyproject.toml b/pyproject.toml
index f8e949739e..3f81303bb1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1481,9 +1481,6 @@ combine-as-imports = true
 "airflow/providers/mysql/transfers/s3_to_mysql.py" = ["D401"]
 "airflow/providers/neo4j/hooks/neo4j.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/oracle/hooks/oracle.py" = ["D401"]
@@ -1499,11 +1496,6 @@ combine-as-imports = true
 "airflow/providers/samba/hooks/samba.py" = ["D401"]
 "airflow/providers/samba/transfers/gcs_to_samba.py" = ["D401"]
 "airflow/providers/segment/hooks/segment.py" = ["D401"]
-"airflow/providers/slack/hooks/slack.py" = ["D401"]
-"airflow/providers/slack/hooks/slack_webhook.py" = ["D401"]
-"airflow/providers/slack/operators/slack.py" = ["D401"]
-"airflow/providers/tableau/hooks/tableau.py" = ["D401"]
-"airflow/providers/tableau/operators/tableau.py" = ["D401"]
 "airflow/providers/telegram/hooks/telegram.py" = ["D401"]
 "airflow/providers/telegram/operators/telegram.py" = ["D401"]
 "airflow/providers/trino/hooks/trino.py" = ["D401"]