diff --git a/airflow/metrics/otel_logger.py b/airflow/metrics/otel_logger.py index 69aa31a836e9e..8726138616228 100644 --- a/airflow/metrics/otel_logger.py +++ b/airflow/metrics/otel_logger.py @@ -84,7 +84,7 @@ def name_is_otel_safe(prefix: str, name: str) -> bool: class SafeOtelLogger: - """Otel Logger""" + """Otel Logger.""" def __init__(self, otel_provider, prefix: str = "airflow", allow_list_validator=AllowListValidator()): self.otel: Callable = otel_provider diff --git a/airflow/metrics/validators.py b/airflow/metrics/validators.py index cedfa2e6494d8..5b7e74aa2d104 100644 --- a/airflow/metrics/validators.py +++ b/airflow/metrics/validators.py @@ -109,6 +109,7 @@ def stat_name_otel_handler( ) -> str: """ Verifies that a proposed prefix and name combination will meet OpenTelemetry naming standards. + See: https://opentelemetry.io/docs/reference/specification/metrics/api/#instrument-name-syntax :param stat_prefix: The proposed prefix applied to all metric names. diff --git a/airflow/migrations/env.py b/airflow/migrations/env.py index 9f97195a6d9c4..c521654c1c709 100644 --- a/airflow/migrations/env.py +++ b/airflow/migrations/env.py @@ -28,7 +28,7 @@ def include_object(_, name, type_, *args): - """Filter objects for autogenerating revisions""" + """Filter objects for autogenerating revisions.""" # Ignore _anything_ to do with Celery, or FlaskSession's tables if type_ == "table" and (name.startswith("celery_") or name == "session"): return False diff --git a/airflow/migrations/utils.py b/airflow/migrations/utils.py index 74237f916cda3..c1182287a67ce 100644 --- a/airflow/migrations/utils.py +++ b/airflow/migrations/utils.py @@ -29,6 +29,7 @@ def get_mssql_table_constraints(conn, table_name) -> dict[str, dict[str, list[st is missing the primary key constraint name and the name is auto-generated by the SQL server. so this function helps to retrieve any primary or unique constraint name. + :param conn: sql connection object :param table_name: table name :return: a dictionary of ((constraint name, constraint type), column name) of table diff --git a/airflow/models/variable.py b/airflow/models/variable.py index 75759be1a2c6d..1051f889edbe9 100644 --- a/airflow/models/variable.py +++ b/airflow/models/variable.py @@ -127,7 +127,7 @@ def get( default_var: Any = __NO_DEFAULT_SENTINEL, deserialize_json: bool = False, ) -> Any: - """Gets a value for an Airflow Variable Key + """Gets a value for an Airflow Variable Key. :param key: Variable Key :param default_var: Default value of the Variable if the Variable doesn't exist diff --git a/airflow/providers/amazon/aws/triggers/glue.py b/airflow/providers/amazon/aws/triggers/glue.py index fbb4d83eb0c1f..71df2f6cb5d15 100644 --- a/airflow/providers/amazon/aws/triggers/glue.py +++ b/airflow/providers/amazon/aws/triggers/glue.py @@ -25,7 +25,7 @@ class GlueJobCompleteTrigger(BaseTrigger): """ - Watches for a glue job, triggers when it finishes + Watches for a glue job, triggers when it finishes. :param job_name: glue job name :param run_id: the ID of the specific run to watch for that job diff --git a/airflow/providers/amazon/aws/triggers/glue_crawler.py b/airflow/providers/amazon/aws/triggers/glue_crawler.py index 3d058cf3f5b2f..e891e87627f78 100644 --- a/airflow/providers/amazon/aws/triggers/glue_crawler.py +++ b/airflow/providers/amazon/aws/triggers/glue_crawler.py @@ -28,7 +28,7 @@ class GlueCrawlerCompleteTrigger(BaseTrigger): """ - Watches for a glue crawl, triggers when it finishes + Watches for a glue crawl, triggers when it finishes. :param crawler_name: name of the crawler to watch :param poll_interval: The amount of time in seconds to wait between attempts. diff --git a/airflow/providers/cncf/kubernetes/operators/resource.py b/airflow/providers/cncf/kubernetes/operators/resource.py index 9515e5b7e5e56..d70a138a412d8 100644 --- a/airflow/providers/cncf/kubernetes/operators/resource.py +++ b/airflow/providers/cncf/kubernetes/operators/resource.py @@ -14,7 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -"""Manage a Kubernetes Resource""" +"""Manage a Kubernetes Resource.""" from __future__ import annotations diff --git a/airflow/providers/docker/operators/docker.py b/airflow/providers/docker/operators/docker.py index 14e6bef379f43..0a20b28dc90b7 100644 --- a/airflow/providers/docker/operators/docker.py +++ b/airflow/providers/docker/operators/docker.py @@ -500,7 +500,7 @@ def on_kill(self) -> None: @staticmethod def unpack_environment_variables(env_str: str) -> dict: - r"""Parse environment variables from the string + r"""Parse environment variables from the string. :param env_str: environment variables in the ``{key}={value}`` format, separated by a ``\n`` (newline) diff --git a/airflow/providers/snowflake/hooks/snowflake_sql_api.py b/airflow/providers/snowflake/hooks/snowflake_sql_api.py index 816071b6f3dd3..0d808291ffa07 100644 --- a/airflow/providers/snowflake/hooks/snowflake_sql_api.py +++ b/airflow/providers/snowflake/hooks/snowflake_sql_api.py @@ -80,7 +80,7 @@ def __init__( self.private_key: Any = None def get_private_key(self) -> None: - """Gets the private key from snowflake connection""" + """Gets the private key from snowflake connection.""" conn = self.get_connection(self.snowflake_conn_id) # If private_key_file is specified in the extra json, load the contents of the file as a private key. @@ -120,7 +120,7 @@ def execute_query( self, sql: str, statement_count: int, query_tag: str = "", bindings: dict[str, Any] | None = None ) -> list[str]: """ - Using SnowflakeSQL API, run the query in snowflake by making API request + Using SnowflakeSQL API, run the query in snowflake by making API request. :param sql: the sql string to be executed with possibly multiple statements :param statement_count: set the MULTI_STATEMENT_COUNT field to the number of SQL statements @@ -170,7 +170,7 @@ def execute_query( def get_headers(self) -> dict[str, Any]: """Based on the private key, and with connection details JWT Token is generated and header - is formed + is formed. """ if not self.private_key: self.get_private_key() @@ -196,7 +196,7 @@ def get_headers(self) -> dict[str, Any]: def get_request_url_header_params(self, query_id: str) -> tuple[dict[str, Any], dict[str, Any], str]: """ - Build the request header Url with account name identifier and query id from the connection params + Build the request header Url with account name identifier and query id from the connection params. :param query_id: statement handles query ids for the individual statements. """ @@ -210,7 +210,7 @@ def get_request_url_header_params(self, query_id: str) -> tuple[dict[str, Any], def check_query_output(self, query_ids: list[str]) -> None: """ Based on the query ids passed as the parameter make HTTP request to snowflake SQL API and logs - the response + the response. :param query_ids: statement handles query id for the individual statements. """ diff --git a/airflow/providers/snowflake/operators/snowflake.py b/airflow/providers/snowflake/operators/snowflake.py index 3e911b8613878..b7e1dbe3f1534 100644 --- a/airflow/providers/snowflake/operators/snowflake.py +++ b/airflow/providers/snowflake/operators/snowflake.py @@ -504,7 +504,7 @@ def execute(self, context: Context) -> None: self._hook.check_query_output(self.query_ids) def poll_on_queries(self): - """Poll on requested queries""" + """Poll on requested queries.""" queries_in_progress = set(self.query_ids) statement_success_status = {} statement_error_status = {} diff --git a/airflow/utils/hashlib_wrapper.py b/airflow/utils/hashlib_wrapper.py index dfdf8b73d87ef..25f02e5c3ad7e 100644 --- a/airflow/utils/hashlib_wrapper.py +++ b/airflow/utils/hashlib_wrapper.py @@ -30,10 +30,10 @@ def md5(__string: ReadableBuffer = b"") -> hashlib._Hash: """ Safely allows calling the hashlib.md5 function with the "usedforsecurity" disabled when specified in the configuration. + :param string: The data to hash. Default to empty str byte. :return: The hashed value. - :rtype: _Hash """ if PY39: return hashlib.md5(__string, usedforsecurity=False) # type: ignore diff --git a/airflow/www/views.py b/airflow/www/views.py index 3e5cddb3a52bd..04671e6f5338d 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -3795,7 +3795,7 @@ def grid_data(self): ] ) def historical_metrics_data(self): - """Returns cluster activity historical metrics""" + """Returns cluster activity historical metrics.""" start_date = _safe_parse_datetime(request.args.get("start_date")) end_date = _safe_parse_datetime(request.args.get("end_date")) with create_session() as session: diff --git a/docs/apache-airflow/img/airflow_erd.sha256 b/docs/apache-airflow/img/airflow_erd.sha256 index 55c5dd9ebd979..0536bf30d2272 100644 --- a/docs/apache-airflow/img/airflow_erd.sha256 +++ b/docs/apache-airflow/img/airflow_erd.sha256 @@ -1 +1 @@ -84df376cc094d640d7d04b46e4f4becd48fcd2e8ce0996c590b4293f22dbda44 \ No newline at end of file +4bd168cc3731503483240260d78ddf0b610de6c79345b0cc4c749a92451e3b1d \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index bcfd856b3f460..d2aa3ec1fcfa1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,8 @@ extend-exclude = [ "airflow/providers/google/ads/_vendor/*", # The files generated by stubgen aren't 100% valid syntax it turns out, and we don't ship them, so we can # ignore them in ruff - "airflow/providers/common/sql/*/*.pyi" + "airflow/providers/common/sql/*/*.pyi", + "airflow/migrations/versions/*.py" ] extend-select = [ @@ -53,7 +54,7 @@ extend-select = [ "D106", "D2", "D3", - # "D400", WIP: see #31135 + "D400", # "D401", # Not enabled by ruff, but we don't want it "D402", "D403",