This is an automated email from the ASF dual-hosted git repository.
potiuk 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 bb414f0122 Added D401 support to http, smtp and sftp provider (#37303)
bb414f0122 is described below
commit bb414f012246aa9874e7c5e84388a1487bbd5bd3
Author: Rohit Gupta <[email protected]>
AuthorDate: Sat Feb 10 19:13:07 2024 +0530
Added D401 support to http, smtp and sftp provider (#37303)
---
airflow/providers/http/operators/http.py | 2 +-
airflow/providers/http/triggers/http.py | 8 ++++----
airflow/providers/sftp/decorators/sensors/sftp.py | 2 +-
airflow/providers/sftp/hooks/sftp.py | 10 +++++-----
airflow/providers/sftp/operators/sftp.py | 2 +-
airflow/providers/sftp/sensors/sftp.py | 2 +-
airflow/providers/sftp/triggers/sftp.py | 4 ++--
airflow/providers/smtp/hooks/smtp.py | 6 +++---
pyproject.toml | 8 --------
9 files changed, 18 insertions(+), 26 deletions(-)
diff --git a/airflow/providers/http/operators/http.py
b/airflow/providers/http/operators/http.py
index b13e8ff50a..3c04a88573 100644
--- a/airflow/providers/http/operators/http.py
+++ b/airflow/providers/http/operators/http.py
@@ -233,7 +233,7 @@ class HttpOperator(BaseOperator):
self, context: Context, event: dict, paginated_responses: None |
list[Response] = None
):
"""
- Callback for when the trigger fires - returns immediately.
+ Execute callback when the trigger fires; returns immediately.
Relies on trigger to throw an exception, otherwise it assumes
execution was successful.
"""
diff --git a/airflow/providers/http/triggers/http.py
b/airflow/providers/http/triggers/http.py
index 52b76a0104..e5f94a30a7 100644
--- a/airflow/providers/http/triggers/http.py
+++ b/airflow/providers/http/triggers/http.py
@@ -71,7 +71,7 @@ class HttpTrigger(BaseTrigger):
self.extra_options = extra_options
def serialize(self) -> tuple[str, dict[str, Any]]:
- """Serializes HttpTrigger arguments and classpath."""
+ """Serialize HttpTrigger arguments and classpath."""
return (
"airflow.providers.http.triggers.http.HttpTrigger",
{
@@ -86,7 +86,7 @@ class HttpTrigger(BaseTrigger):
)
async def run(self) -> AsyncIterator[TriggerEvent]:
- """Makes a series of asynchronous http calls via an http hook."""
+ """Make a series of asynchronous http calls via a http hook."""
hook = HttpAsyncHook(
method=self.method,
http_conn_id=self.http_conn_id,
@@ -162,7 +162,7 @@ class HttpSensorTrigger(BaseTrigger):
self.poke_interval = poke_interval
def serialize(self) -> tuple[str, dict[str, Any]]:
- """Serializes HttpTrigger arguments and classpath."""
+ """Serialize HttpTrigger arguments and classpath."""
return (
"airflow.providers.http.triggers.http.HttpSensorTrigger",
{
@@ -176,7 +176,7 @@ class HttpSensorTrigger(BaseTrigger):
)
async def run(self) -> AsyncIterator[TriggerEvent]:
- """Makes a series of asynchronous http calls via an http hook."""
+ """Make a series of asynchronous http calls via an http hook."""
hook = self._get_async_hook()
while True:
try:
diff --git a/airflow/providers/sftp/decorators/sensors/sftp.py
b/airflow/providers/sftp/decorators/sensors/sftp.py
index 9bdf670beb..d12b3ee761 100644
--- a/airflow/providers/sftp/decorators/sensors/sftp.py
+++ b/airflow/providers/sftp/decorators/sensors/sftp.py
@@ -59,7 +59,7 @@ class _DecoratedSFTPSensor(SFTPSensor):
def sftp_sensor_task(python_callable: Callable | None = None, **kwargs) ->
TaskDecorator:
"""
- Wraps a function into an Airflow operator.
+ Wrap a function into an Airflow operator.
Accepts kwargs for operator kwarg. Can be reused in a single DAG.
:param python_callable: Function to decorate
diff --git a/airflow/providers/sftp/hooks/sftp.py
b/airflow/providers/sftp/hooks/sftp.py
index eb13ddf555..e7630fd10c 100644
--- a/airflow/providers/sftp/hooks/sftp.py
+++ b/airflow/providers/sftp/hooks/sftp.py
@@ -117,7 +117,7 @@ class SFTPHook(SSHHook):
super().__init__(*args, **kwargs)
def get_conn(self) -> paramiko.SFTPClient: # type: ignore[override]
- """Opens an SFTP connection to the remote host."""
+ """Open an SFTP connection to the remote host."""
if self.conn is None:
# TODO: remove support for ssh_hook when it is removed from
SFTPOperator
if self.ssh_hook is not None:
@@ -127,7 +127,7 @@ class SFTPHook(SSHHook):
return self.conn
def close_conn(self) -> None:
- """Closes the SFTP connection."""
+ """Close the SFTP connection."""
if self.conn is not None:
self.conn.close()
self.conn = None
@@ -516,7 +516,7 @@ class SFTPHookAsync(BaseHook):
return ssh_client_conn
async def list_directory(self, path: str = "") -> list[str] | None:
- """Returns a list of files on the SFTP server at the provided path."""
+ """Return a list of files on the SFTP server at the provided path."""
ssh_conn = await self._get_conn()
sftp_client = await ssh_conn.start_sftp_client()
try:
@@ -526,7 +526,7 @@ class SFTPHookAsync(BaseHook):
return None
async def read_directory(self, path: str = "") ->
Sequence[asyncssh.sftp.SFTPName] | None:
- """Returns a list of files along with their attributes on the SFTP
server at the provided path."""
+ """Return a list of files along with their attributes on the SFTP
server at the provided path."""
ssh_conn = await self._get_conn()
sftp_client = await ssh_conn.start_sftp_client()
try:
@@ -551,7 +551,7 @@ class SFTPHookAsync(BaseHook):
async def get_mod_time(self, path: str) -> str:
"""
- Makes SFTP async connection.
+ Make SFTP async connection.
Looks for last modified time in the specific file path and returns
last modification time for
the file path.
diff --git a/airflow/providers/sftp/operators/sftp.py
b/airflow/providers/sftp/operators/sftp.py
index 466c9fe729..64367716a0 100644
--- a/airflow/providers/sftp/operators/sftp.py
+++ b/airflow/providers/sftp/operators/sftp.py
@@ -194,7 +194,7 @@ class SFTPOperator(BaseOperator):
def get_openlineage_facets_on_start(self):
"""
- Returns OpenLineage datasets.
+ Return OpenLineage datasets.
Dataset will have the following structure:
input: file://<local_host>/path
diff --git a/airflow/providers/sftp/sensors/sftp.py
b/airflow/providers/sftp/sensors/sftp.py
index 4a02669682..af13b4fab3 100644
--- a/airflow/providers/sftp/sensors/sftp.py
+++ b/airflow/providers/sftp/sensors/sftp.py
@@ -155,7 +155,7 @@ class SFTPSensor(BaseSensorOperator):
def execute_complete(self, context: dict[str, Any], event: Any = None) ->
None:
"""
- Callback for when the trigger fires - returns immediately.
+ Execute callback when the trigger fires; returns immediately.
Relies on trigger to throw an exception, otherwise it assumes
execution was
successful.
diff --git a/airflow/providers/sftp/triggers/sftp.py
b/airflow/providers/sftp/triggers/sftp.py
index 9220766262..9bb1f289e0 100644
--- a/airflow/providers/sftp/triggers/sftp.py
+++ b/airflow/providers/sftp/triggers/sftp.py
@@ -61,7 +61,7 @@ class SFTPTrigger(BaseTrigger):
self.poke_interval = poke_interval
def serialize(self) -> tuple[str, dict[str, Any]]:
- """Serializes SFTPTrigger arguments and classpath."""
+ """Serialize SFTPTrigger arguments and classpath."""
return (
"airflow.providers.sftp.triggers.sftp.SFTPTrigger",
{
@@ -75,7 +75,7 @@ class SFTPTrigger(BaseTrigger):
async def run(self) -> AsyncIterator[TriggerEvent]:
"""
- Makes a series of asynchronous calls to sftp servers via async sftp
hook. It yields a Trigger.
+ Make a series of asynchronous calls to sftp servers via async sftp
hook. It yields a Trigger.
- If file matching file pattern exists at the specified path return it,
- If file pattern was not provided, it looks directly into the
specific path which was provided.
diff --git a/airflow/providers/smtp/hooks/smtp.py
b/airflow/providers/smtp/hooks/smtp.py
index 4712180eac..e3da40e9d8 100644
--- a/airflow/providers/smtp/hooks/smtp.py
+++ b/airflow/providers/smtp/hooks/smtp.py
@@ -136,7 +136,7 @@ class SmtpHook(BaseHook):
@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
@@ -308,7 +308,7 @@ class SmtpHook(BaseHook):
def _get_email_address_list(self, addresses: str | Iterable[str]) ->
list[str]:
"""
- Returns a list of email addresses from the provided input.
+ Return a list of email addresses from the provided input.
:param addresses: A string or iterable of strings containing email
addresses.
:return: A list of email addresses.
@@ -380,7 +380,7 @@ class SmtpHook(BaseHook):
@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
- """Returns custom field behaviour."""
+ """Return custom field behaviour."""
return {
"hidden_fields": ["schema", "extra"],
"relabeling": {},
diff --git a/pyproject.toml b/pyproject.toml
index f93cd2aeb6..4ab33e9c1e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1492,8 +1492,6 @@ combine-as-imports = true
"airflow/providers/google/suite/hooks/sheets.py" = ["D401"]
"airflow/providers/hashicorp/_internal_client/vault_client.py" = ["D401"]
"airflow/providers/hashicorp/hooks/vault.py" = ["D401"]
-"airflow/providers/http/operators/http.py" = ["D401"]
-"airflow/providers/http/triggers/http.py" = ["D401"]
"airflow/providers/imap/hooks/imap.py" = ["D401"]
"airflow/providers/microsoft/azure/hooks/adx.py" = ["D401"]
"airflow/providers/microsoft/azure/hooks/asb.py" = ["D401"]
@@ -1542,15 +1540,9 @@ 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/sftp/decorators/sensors/sftp.py" = ["D401"]
-"airflow/providers/sftp/hooks/sftp.py" = ["D401"]
-"airflow/providers/sftp/operators/sftp.py" = ["D401"]
-"airflow/providers/sftp/sensors/sftp.py" = ["D401"]
-"airflow/providers/sftp/triggers/sftp.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/smtp/hooks/smtp.py" = ["D401"]
"airflow/providers/tableau/hooks/tableau.py" = ["D401"]
"airflow/providers/tableau/operators/tableau.py" = ["D401"]
"airflow/providers/telegram/hooks/telegram.py" = ["D401"]