Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions airflow/providers/common/io/xcom/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@


def _is_relative_to(o: ObjectStoragePath, other: ObjectStoragePath) -> bool:
"""This is a port of the pathlib.Path.is_relative_to method. It is not available in python 3.8."""
"""Return whether or not this path is relative to the other path.

This is a port of the pathlib.Path.is_relative_to method. It is not available in python 3.8.
"""
if hasattr(o, "is_relative_to"):
return o.is_relative_to(other)

Expand All @@ -51,7 +54,7 @@ def _is_relative_to(o: ObjectStoragePath, other: ObjectStoragePath) -> bool:


def _get_compression_suffix(compression: str) -> str:
"""This returns the compression suffix for the given compression.
"""Return the compression suffix for the given compression.

:raises ValueError: if the compression is not supported
"""
Expand All @@ -73,7 +76,7 @@ class XComObjectStoreBackend(BaseXCom):

@staticmethod
def _get_key(data: str) -> str:
"""This gets the key from the url and normalizes it to be relative to the configured path.
"""Get the key from the url and normalizes it to be relative to the configured path.

:raises ValueError: if the key is not relative to the configured path
:raises TypeError: if the url is not a valid url or cannot be split
Expand Down
6 changes: 2 additions & 4 deletions airflow/providers/databricks/hooks/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def __init__(
super().__init__(databricks_conn_id, timeout_seconds, retry_limit, retry_delay, retry_args, caller)

def create_job(self, json: dict) -> int:
"""
Utility function to call the ``api/2.1/jobs/create`` endpoint.
"""Call the ``api/2.1/jobs/create`` endpoint.

:param json: The data used in the body of the request to the ``create`` endpoint.
:return: the job_id as an int
Expand All @@ -206,8 +205,7 @@ def create_job(self, json: dict) -> int:
return response["job_id"]

def reset_job(self, job_id: str, json: dict) -> None:
"""
Utility function to call the ``api/2.1/jobs/reset`` endpoint.
"""Call the ``api/2.1/jobs/reset`` endpoint.

:param json: The data used in the new_settings of the request to the ``reset`` endpoint.
"""
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/databricks/operators/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def __init__(
databricks_retry_args: dict[Any, Any] | None = None,
**kwargs,
) -> None:
"""Creates a new ``DatabricksCreateJobsOperator``."""
"""Create a new ``DatabricksCreateJobsOperator``."""
super().__init__(**kwargs)
self.json = json or {}
self.databricks_conn_id = databricks_conn_id
Expand Down
6 changes: 3 additions & 3 deletions airflow/providers/hashicorp/_internal_client/vault_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def get_secret(self, secret_path: str, secret_version: int | None = None) -> dic

def get_secret_metadata(self, secret_path: str) -> dict | None:
"""
Reads secret metadata (including versions) from the engine. It is only valid for KV version 2.
Read secret metadata (including versions) from the engine. It is only valid for KV version 2.

:param secret_path: The path of the secret.
:return: secret metadata. This is a Dict containing metadata for the secret.
Expand All @@ -410,7 +410,7 @@ def get_secret_including_metadata(
self, secret_path: str, secret_version: int | None = None
) -> dict | None:
"""
Reads secret including metadata. It is only valid for KV version 2.
Read secret including metadata. It is only valid for KV version 2.

See https://hvac.readthedocs.io/en/stable/usage/secrets_engines/kv_v2.html for details.

Expand Down Expand Up @@ -444,7 +444,7 @@ def create_or_update_secret(
self, secret_path: str, secret: dict, method: str | None = None, cas: int | None = None
) -> Response:
"""
Creates or updates secret.
Create or updates secret.

:param secret_path: The path of the secret.
:param secret: Secret to create or update for the path specified
Expand Down
12 changes: 6 additions & 6 deletions airflow/providers/hashicorp/hooks/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def _get_radius_parameters_from_connection(

def get_conn(self) -> hvac.Client:
"""
Retrieves connection to Vault.
Retrieve connection to Vault.

:return: connection used.
"""
Expand All @@ -313,7 +313,7 @@ def get_secret(self, secret_path: str, secret_version: int | None = None) -> dic

def get_secret_metadata(self, secret_path: str) -> dict | None:
"""
Reads secret metadata (including versions) from the engine. It is only valid for KV version 2.
Read secret metadata (including versions) from the engine. It is only valid for KV version 2.

:param secret_path: Path to read from
:return: secret metadata. This is a Dict containing metadata for the secret.
Expand All @@ -327,7 +327,7 @@ def get_secret_including_metadata(
self, secret_path: str, secret_version: int | None = None
) -> dict | None:
"""
Reads secret including metadata. It is only valid for KV version 2.
Read secret including metadata. It is only valid for KV version 2.

See https://hvac.readthedocs.io/en/stable/usage/secrets_engines/kv_v2.html for details.

Expand All @@ -345,7 +345,7 @@ def create_or_update_secret(
self, secret_path: str, secret: dict, method: str | None = None, cas: int | None = None
) -> Response:
"""
Creates or updates secret.
Create or updates secret.

:param secret_path: Path to read from
:param secret: Secret to create or update for the path specified
Expand All @@ -368,7 +368,7 @@ def create_or_update_secret(

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
"""Return connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import BooleanField, IntegerField, StringField
Expand Down Expand Up @@ -405,7 +405,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 field behaviour."""
return {
"hidden_fields": ["extra"],
"relabeling": {},
Expand Down
18 changes: 9 additions & 9 deletions airflow/providers/imap/hooks/imap.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def has_mail_attachment(
self, name: str, *, check_regex: bool = False, mail_folder: str = "INBOX", mail_filter: str = "All"
) -> bool:
"""
Checks the mail folder for mails containing attachments with the given name.
Check the mail folder for mails containing attachments with the given name.

:param name: The name of the attachment that will be searched for.
:param check_regex: Checks the name for a regular expression.
Expand All @@ -145,7 +145,7 @@ def retrieve_mail_attachments(
not_found_mode: str = "raise",
) -> list[tuple]:
"""
Retrieves mail's attachments in the mail folder by its name.
Retrieve mail's attachments in the mail folder by its name.

:param name: The name of the attachment that will be downloaded.
:param check_regex: Checks the name for a regular expression.
Expand Down Expand Up @@ -181,7 +181,7 @@ def download_mail_attachments(
not_found_mode: str = "raise",
) -> None:
"""
Downloads mail's attachments in the mail folder by its name to the local directory.
Download mail's attachments in the mail folder by its name to the local directory.

:param name: The name of the attachment that will be downloaded.
:param local_output_directory: The output directory on the local machine
Expand Down Expand Up @@ -304,7 +304,7 @@ def __init__(self, mail_body: str) -> None:

def has_attachments(self) -> bool:
"""
Checks the mail for a attachments.
Check the mail for a attachments.

:returns: True if it has attachments and False if not.
"""
Expand All @@ -314,7 +314,7 @@ def get_attachments_by_name(
self, name: str, check_regex: bool, find_first: bool = False
) -> list[tuple[Any, Any]]:
"""
Gets all attachments by name for the mail.
Get all attachments by name for the mail.

:param name: The name of the attachment to look for.
:param check_regex: Checks the name for a regular expression.
Expand Down Expand Up @@ -356,15 +356,15 @@ def __init__(self, part: Any) -> None:

def is_attachment(self) -> bool:
"""
Checks if the part is a valid mail attachment.
Check if the part is a valid mail attachment.

:returns: True if it is an attachment and False if not.
"""
return self.part.get_content_maintype() != "multipart" and self.part.get("Content-Disposition")

def has_matching_name(self, name: str) -> tuple[Any, Any] | None:
"""
Checks if the given name matches the part's name.
Check if the given name matches the part's name.

:param name: The name to look for.
:returns: True if it matches the name (including regular expression).
Expand All @@ -373,7 +373,7 @@ def has_matching_name(self, name: str) -> tuple[Any, Any] | None:

def has_equal_name(self, name: str) -> bool:
"""
Checks if the given name is equal to the part's name.
Check if the given name is equal to the part's name.

:param name: The name to look for.
:returns: True if it is equal to the given name.
Expand All @@ -382,7 +382,7 @@ def has_equal_name(self, name: str) -> bool:

def get_file(self) -> tuple:
"""
Gets the file including name and payload.
Get the file including name and payload.

:returns: the part's name and payload.
"""
Expand Down
26 changes: 13 additions & 13 deletions airflow/providers/mongo/hooks/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __exit__(
self.client = None

def get_conn(self) -> MongoClient:
"""Fetches PyMongo Client."""
"""Fetch PyMongo Client."""
if self.client is not None:
return self.client

Expand Down Expand Up @@ -167,7 +167,7 @@ def get_collection(
self, mongo_collection: str, mongo_db: str | None = None
) -> pymongo.collection.Collection:
"""
Fetches a mongo collection object for querying.
Fetch a mongo collection object for querying.

Uses connection schema as DB unless specified.
"""
Expand All @@ -180,7 +180,7 @@ def aggregate(
self, mongo_collection: str, aggregate_query: list, mongo_db: str | None = None, **kwargs
) -> pymongo.command_cursor.CommandCursor:
"""
Runs an aggregation pipeline and returns the results.
Run an aggregation pipeline and returns the results.

https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.aggregate
https://pymongo.readthedocs.io/en/stable/examples/aggregation.html
Expand Down Expand Up @@ -223,7 +223,7 @@ def find(
**kwargs,
) -> pymongo.cursor.Cursor | Any | None:
"""
Runs a mongo find query and returns the results.
Run a mongo find query and returns the results.

https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.find
"""
Expand All @@ -238,7 +238,7 @@ def insert_one(
self, mongo_collection: str, doc: dict, mongo_db: str | None = None, **kwargs
) -> pymongo.results.InsertOneResult:
"""
Inserts a single document into a mongo collection.
Insert a single document into a mongo collection.

https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.insert_one
"""
Expand All @@ -250,7 +250,7 @@ def insert_many(
self, mongo_collection: str, docs: Iterable[dict], mongo_db: str | None = None, **kwargs
) -> pymongo.results.InsertManyResult:
"""
Inserts many docs into a mongo collection.
Insert many docs into a mongo collection.

https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.insert_many
"""
Expand All @@ -267,7 +267,7 @@ def update_one(
**kwargs,
) -> pymongo.results.UpdateResult:
"""
Updates a single document in a mongo collection.
Update a single document in a mongo collection.

https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.update_one

Expand All @@ -291,7 +291,7 @@ def update_many(
**kwargs,
) -> pymongo.results.UpdateResult:
"""
Updates one or more documents in a mongo collection.
Update one or more documents in a mongo collection.

https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.update_many

Expand All @@ -314,7 +314,7 @@ def replace_one(
**kwargs,
) -> pymongo.results.UpdateResult:
"""
Replaces a single document in a mongo collection.
Replace a single document in a mongo collection.

https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.replace_one

Expand Down Expand Up @@ -347,7 +347,7 @@ def replace_many(
**kwargs,
) -> pymongo.results.BulkWriteResult:
"""
Replaces many documents in a mongo collection.
Replace many documents in a mongo collection.

Uses bulk_write with multiple ReplaceOne operations
https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.bulk_write
Expand Down Expand Up @@ -384,7 +384,7 @@ def delete_one(
self, mongo_collection: str, filter_doc: dict, mongo_db: str | None = None, **kwargs
) -> pymongo.results.DeleteResult:
"""
Deletes a single document in a mongo collection.
Delete a single document in a mongo collection.

https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.delete_one

Expand All @@ -401,7 +401,7 @@ def delete_many(
self, mongo_collection: str, filter_doc: dict, mongo_db: str | None = None, **kwargs
) -> pymongo.results.DeleteResult:
"""
Deletes one or more documents in a mongo collection.
Delete one or more documents in a mongo collection.

https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.delete_many

Expand All @@ -423,7 +423,7 @@ def distinct(
**kwargs,
) -> list[Any]:
"""
Returns a list of distinct values for the given key across a collection.
Return a list of distinct values for the given key across a collection.

https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.distinct

Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/mysql/hooks/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _get_conn_config_mysql_connector_python(self, conn: Connection) -> dict:

def get_conn(self) -> MySQLConnectionTypes:
"""
Connection to a MySQL database.
Get connection to a MySQL database.

Establishes a connection to a mysql database
by extracting the connection configuration from the Airflow connection.
Expand Down Expand Up @@ -268,7 +268,7 @@ def bulk_load_custom(
self, table: str, tmp_file: str, duplicate_key_handling: str = "IGNORE", extra_options: str = ""
) -> None:
"""
A more configurable way to load local data from a file into the database.
Load local data from a file into the database in a more configurable way.

.. warning:: According to the mysql docs using this function is a
`security risk <https://dev.mysql.com/doc/refman/8.0/en/load-data-local.html>`_.
Expand Down Expand Up @@ -299,7 +299,7 @@ def bulk_load_custom(
conn.close() # type: ignore[misc]

def get_openlineage_database_info(self, connection):
"""Returns MySQL specific information for OpenLineage."""
"""Return MySQL specific information for OpenLineage."""
from airflow.providers.openlineage.sqlparser import DatabaseInfo

return DatabaseInfo(
Expand All @@ -316,7 +316,7 @@ def get_openlineage_database_info(self, connection):
)

def get_openlineage_database_dialect(self, _):
"""Returns database dialect."""
"""Return database dialect."""
return "mysql"

def get_openlineage_default_schema(self):
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/mysql/transfers/s3_to_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(

def execute(self, context: Context) -> None:
"""
Executes the transfer operation from S3 to MySQL.
Execute the transfer operation from S3 to MySQL.

:param context: The context that is being provided when executing.
"""
Expand Down
Loading