Skip to content

Commit

Permalink
Enable enforcing pydocstyle rule D213 in ruff. (apache#40448)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferruzzi authored Jun 27, 2024
1 parent 3eea44e commit a62bd83
Show file tree
Hide file tree
Showing 416 changed files with 2,429 additions and 1,216 deletions.
15 changes: 10 additions & 5 deletions airflow/api/client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def __init__(self, api_base_url, auth=None, session: httpx.Client | None = None)
self._session.auth = auth

def trigger_dag(self, dag_id, run_id=None, conf=None, execution_date=None, replace_microseconds=True):
"""Create a dag run for the specified dag.
"""
Create a dag run for the specified dag.
:param dag_id:
:param run_id:
Expand All @@ -44,14 +45,16 @@ def trigger_dag(self, dag_id, run_id=None, conf=None, execution_date=None, repla
raise NotImplementedError()

def delete_dag(self, dag_id):
"""Delete all DB records related to the specified dag.
"""
Delete all DB records related to the specified dag.
:param dag_id:
"""
raise NotImplementedError()

def get_pool(self, name):
"""Get pool.
"""
Get pool.
:param name: pool name
"""
Expand All @@ -62,7 +65,8 @@ def get_pools(self):
raise NotImplementedError()

def create_pool(self, name, slots, description, include_deferred):
"""Create a pool.
"""
Create a pool.
:param name: pool name
:param slots: pool slots amount
Expand All @@ -72,7 +76,8 @@ def create_pool(self, name, slots, description, include_deferred):
raise NotImplementedError()

def delete_pool(self, name):
"""Delete pool.
"""
Delete pool.
:param name: pool name
"""
Expand Down
27 changes: 18 additions & 9 deletions airflow/api/client/json_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@


class Client(api_client.Client):
"""Json API client implementation.
"""
Json API client implementation.
This client is used to interact with a Json API server and perform various actions
such as triggering DAG runs,deleting DAGs, interacting with pools, and getting lineage information.
"""

def _request(self, url: str, json=None, method: str = "GET") -> dict:
"""Make a request to the Json API server.
"""
Make a request to the Json API server.
:param url: The URL to send the request to.
:param method: The HTTP method to use (e.g. "GET", "POST", "DELETE").
Expand All @@ -56,7 +58,8 @@ def _request(self, url: str, json=None, method: str = "GET") -> dict:
return resp.json()

def trigger_dag(self, dag_id, run_id=None, conf=None, execution_date=None, replace_microseconds=True):
"""Trigger a DAG run.
"""
Trigger a DAG run.
:param dag_id: The ID of the DAG to trigger.
:param run_id: The ID of the DAG run to create. If not provided, a default ID will be generated.
Expand All @@ -76,7 +79,8 @@ def trigger_dag(self, dag_id, run_id=None, conf=None, execution_date=None, repla
return self._request(url, method="POST", json=data)["message"]

def delete_dag(self, dag_id: str):
"""Delete a DAG.
"""
Delete a DAG.
:param dag_id: The ID of the DAG to delete.
:return: A message indicating the status of the DAG delete operation.
Expand All @@ -87,7 +91,8 @@ def delete_dag(self, dag_id: str):
return data["message"]

def get_pool(self, name: str):
"""Get information about a specific pool.
"""
Get information about a specific pool.
:param name: The name of the pool to retrieve information for.
:return: A tuple containing the name of the pool, the number of
Expand All @@ -99,7 +104,8 @@ def get_pool(self, name: str):
return pool["pool"], pool["slots"], pool["description"]

def get_pools(self):
"""Get a list of all pools.
"""
Get a list of all pools.
:return: A list of tuples, each containing the name of a pool,
the number of slots in the pool, and a description of the pool.
Expand All @@ -110,7 +116,8 @@ def get_pools(self):
return [(p["pool"], p["slots"], p["description"]) for p in pools]

def create_pool(self, name: str, slots: int, description: str, include_deferred: bool):
"""Create a new pool.
"""
Create a new pool.
:param name: The name of the pool to create.
:param slots: The number of slots in the pool.
Expand All @@ -131,7 +138,8 @@ def create_pool(self, name: str, slots: int, description: str, include_deferred:
return response["pool"], response["slots"], response["description"], response["include_deferred"]

def delete_pool(self, name: str):
"""Delete a pool.
"""
Delete a pool.
:param name: The name of the pool to delete.
:return: A tuple containing the name of the pool, the number
Expand All @@ -143,7 +151,8 @@ def delete_pool(self, name: str):
return pool["pool"], pool["slots"], pool["description"]

def get_lineage(self, dag_id: str, execution_date: str):
"""Get the lineage of a DAG run.
"""
Get the lineage of a DAG run.
:param dag_id: The ID of the DAG.
:param execution_date: The execution date of the DAG run, in the format "YYYY-MM-DDTHH:MM:SS".
Expand Down
3 changes: 2 additions & 1 deletion airflow/api/common/experimental/get_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
reason="Use DagCode().get_code_by_fileloc() instead", version="2.2.4", category=RemovedInAirflow3Warning
)
def get_code(dag_id: str) -> str:
"""Return python code of a given dag_id.
"""
Return python code of a given dag_id.
:param dag_id: DAG id
:return: code of the DAG
Expand Down
3 changes: 2 additions & 1 deletion airflow/api/common/experimental/get_dag_run_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

@deprecated(reason="Use DagRun().get_state() instead", version="2.2.4", category=RemovedInAirflow3Warning)
def get_dag_run_state(dag_id: str, execution_date: datetime) -> dict[str, str]:
"""Return the Dag Run state identified by the given dag_id and execution_date.
"""
Return the Dag Run state identified by the given dag_id and execution_date.
:param dag_id: DAG id
:param execution_date: execution date
Expand Down
9 changes: 6 additions & 3 deletions airflow/api/common/mark_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def _create_dagruns(
state: DagRunState,
run_type: DagRunType,
) -> Iterable[DagRun]:
"""Infers from data intervals which DAG runs need to be created and does so.
"""
Infers from data intervals which DAG runs need to be created and does so.
:param dag: The DAG to create runs for.
:param infos: List of logical dates and data intervals to evaluate.
Expand Down Expand Up @@ -211,7 +212,8 @@ def _iter_subdag_run_ids(
commit: bool,
confirmed_infos: Iterable[_DagRunInfo],
) -> Iterator[str]:
"""Go through subdag operators and create dag runs.
"""
Go through subdag operators and create dag runs.
We only work within the scope of the subdag. A subdag does not propagate to
its parent DAG, but parent propagates to subdags.
Expand Down Expand Up @@ -250,7 +252,8 @@ def verify_dagruns(
session: SASession,
current_task: Operator,
):
"""Verify integrity of dag_runs.
"""
Verify integrity of dag_runs.
:param dag_runs: dag runs to verify
:param commit: whether dag runs state should be updated
Expand Down
6 changes: 4 additions & 2 deletions airflow/api/common/trigger_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def _trigger_dag(
execution_date: datetime | None = None,
replace_microseconds: bool = True,
) -> list[DagRun | None]:
"""Triggers DAG run.
"""
Triggers DAG run.
:param dag_id: DAG ID
:param dag_bag: DAG Bag model
Expand Down Expand Up @@ -109,7 +110,8 @@ def trigger_dag(
execution_date: datetime | None = None,
replace_microseconds: bool = True,
) -> DagRun | None:
"""Triggers execution of DAG specified by dag_id.
"""
Triggers execution of DAG specified by dag_id.
:param dag_id: DAG ID
:param run_id: ID of the dag_run
Expand Down
3 changes: 2 additions & 1 deletion airflow/api_connexion/endpoints/dag_warning_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def get_dag_warnings(
order_by: str = "timestamp",
session: Session = NEW_SESSION,
) -> APIResponse:
"""Get DAG warnings.
"""
Get DAG warnings.
:param dag_id: the dag_id to optionally filter by
:param warning_type: the warning type to optionally filter by
Expand Down
3 changes: 2 additions & 1 deletion airflow/api_connexion/schemas/dag_run_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class Meta:

@pre_load
def autogenerate(self, data, **kwargs):
"""Auto generate run_id and logical_date if they are not provided.
"""
Auto generate run_id and logical_date if they are not provided.
For compatibility, if `execution_date` is submitted, it is converted
to `logical_date`.
Expand Down
3 changes: 2 additions & 1 deletion airflow/auth/managers/base_auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def __init__(self, appbuilder: AirflowAppBuilder) -> None:

@staticmethod
def get_cli_commands() -> list[CLICommand]:
"""Vends CLI commands to be included in Airflow CLI.
"""
Vends CLI commands to be included in Airflow CLI.
Override this method to expose commands via Airflow CLI to manage this auth manager.
"""
Expand Down
3 changes: 2 additions & 1 deletion airflow/cli/cli_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Produce a CLI parser object from Airflow CLI command configuration.
"""
Produce a CLI parser object from Airflow CLI command configuration.
.. seealso:: :mod:`airflow.cli.cli_config`
"""
Expand Down
3 changes: 2 additions & 1 deletion airflow/cli/commands/connection_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ def connections_import(args):


def _import_helper(file_path: str, overwrite: bool) -> None:
"""Load connections from a file and save them to the DB.
"""
Load connections from a file and save them to the DB.
:param overwrite: Whether to skip or overwrite on collision.
"""
Expand Down
3 changes: 2 additions & 1 deletion airflow/cli/commands/daemon_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def run_command_with_daemon_option(
umask: str = settings.DAEMON_UMASK,
pid_file: str | None = None,
):
"""Run the command in a daemon process if daemon mode enabled or within this process if not.
"""
Run the command in a daemon process if daemon mode enabled or within this process if not.
:param args: the set of arguments passed to the original CLI command
:param process_name: process name used in naming log and PID files for the daemon
Expand Down
3 changes: 2 additions & 1 deletion airflow/cli/commands/provider_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ def config_list(args):

@suppress_logs_and_warning
def lazy_loaded(args):
"""Informs if providers manager has been initialized too early.
"""
Informs if providers manager has been initialized too early.
If provider is initialized, shows the stack trace and exit with error code 1.
"""
Expand Down
6 changes: 4 additions & 2 deletions airflow/cli/commands/task_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@


def _generate_temporary_run_id() -> str:
"""Generate a ``run_id`` for a DAG run that will be created temporarily.
"""
Generate a ``run_id`` for a DAG run that will be created temporarily.
This is used mostly by ``airflow task test`` to create a DAG run that will
be deleted after the task is run.
Expand All @@ -98,7 +99,8 @@ def _get_dag_run(
exec_date_or_run_id: str | None = None,
session: Session | None = None,
) -> tuple[DagRun | DagRunPydantic, bool]:
"""Try to retrieve a DAG run from a string representing either a run ID or logical date.
"""
Try to retrieve a DAG run from a string representing either a run ID or logical date.
This checks DAG runs like this:
Expand Down
3 changes: 2 additions & 1 deletion airflow/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class CliConflictError(Exception):


def is_stdout(fileio: IOBase) -> bool:
"""Check whether a file IO is stdout.
"""
Check whether a file IO is stdout.
The intended use case for this helper is to check whether an argument parsed
with argparse.FileType points to stdout (by setting the path to ``-``). This
Expand Down
6 changes: 4 additions & 2 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ def write( # type: ignore[override]
file.write("\n")

def restore_core_default_configuration(self) -> None:
"""Restore default configuration for core Airflow.
"""
Restore default configuration for core Airflow.
It does not restore configuration for providers. If you want to restore configuration for
providers, you need to call ``load_providers_configuration`` method.
Expand Down Expand Up @@ -810,7 +811,8 @@ def _validate_enums(self):
)

def _validate_sqlite3_version(self):
"""Validate SQLite version.
"""
Validate SQLite version.
Some features in storing rendered fields require SQLite >= 3.15.0.
"""
Expand Down
3 changes: 2 additions & 1 deletion airflow/dag_processing/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,8 @@ def _refresh_dag_dir(self) -> bool:
self.log.exception("Error removing old import errors")

def _iter_dag_filelocs(fileloc: str) -> Iterator[str]:
"""Get "full" paths to DAGs if inside ZIP files.
"""
Get "full" paths to DAGs if inside ZIP files.
This is the format used by the remove/delete functions.
"""
Expand Down
Loading

0 comments on commit a62bd83

Please sign in to comment.