Skip to content

Commit

Permalink
Add D400 pydocstyle check (#31742)
Browse files Browse the repository at this point in the history
* Add D400 pydocstyle check

* Fix static checks
  • Loading branch information
vincbeck committed Jun 7, 2023
1 parent 9e268e1 commit 07ea574
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion airflow/metrics/otel_logger.py
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions airflow/metrics/validators.py
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion airflow/migrations/env.py
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions airflow/migrations/utils.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion airflow/models/variable.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/amazon/aws/triggers/glue.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/amazon/aws/triggers/glue_crawler.py
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/cncf/kubernetes/operators/resource.py
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/docker/operators/docker.py
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions airflow/providers/snowflake/hooks/snowflake_sql_api.py
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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.
"""
Expand All @@ -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.
"""
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/snowflake/operators/snowflake.py
Expand Up @@ -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 = {}
Expand Down
2 changes: 1 addition & 1 deletion airflow/utils/hashlib_wrapper.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion airflow/www/views.py
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/apache-airflow/img/airflow_erd.sha256
@@ -1 +1 @@
84df376cc094d640d7d04b46e4f4becd48fcd2e8ce0996c590b4293f22dbda44
4bd168cc3731503483240260d78ddf0b610de6c79345b0cc4c749a92451e3b1d
5 changes: 3 additions & 2 deletions pyproject.toml
Expand Up @@ -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 = [
Expand All @@ -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",
Expand Down

0 comments on commit 07ea574

Please sign in to comment.