Skip to content

Commit

Permalink
D401 Support in Microsoft providers (apache#37327)
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Kling <[email protected]>
  • Loading branch information
DjVinnii authored Feb 12, 2024
1 parent ca30f00 commit 9d91bb4
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 109 deletions.
6 changes: 3 additions & 3 deletions airflow/providers/microsoft/azure/hooks/adx.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

class AzureDataExplorerHook(BaseHook):
"""
Interacts with Azure Data Explorer (Kusto).
Interact with Azure Data Explorer (Kusto).
**Cluster**:
Expand Down Expand Up @@ -85,7 +85,7 @@ class AzureDataExplorerHook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 BS3PasswordFieldWidget, BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import PasswordField, StringField
Expand All @@ -103,7 +103,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": ["schema", "port", "extra"],
"relabeling": {
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/microsoft/azure/hooks/asb.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BaseAzureServiceBusHook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 PasswordField, StringField
Expand All @@ -62,7 +62,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": ["port", "host", "extra", "login", "password"],
"relabeling": {"schema": "Connection String"},
Expand Down
6 changes: 3 additions & 3 deletions airflow/providers/microsoft/azure/hooks/base_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AzureBaseHook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 StringField
Expand All @@ -62,7 +62,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."""
import json

return {
Expand Down Expand Up @@ -93,7 +93,7 @@ def __init__(self, sdk_client: Any, conn_id: str = "azure_default"):

def get_conn(self) -> Any:
"""
Authenticates the resource using the connection id passed during init.
Authenticate the resource using the connection id passed during init.
:return: the authenticated client.
"""
Expand Down
14 changes: 7 additions & 7 deletions airflow/providers/microsoft/azure/hooks/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AzureBatchHook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 StringField
Expand All @@ -64,7 +64,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": ["schema", "port", "host", "extra"],
"relabeling": {
Expand Down Expand Up @@ -136,7 +136,7 @@ def configure_pool(
**kwargs,
) -> PoolAddParameter:
"""
Configures a pool.
Configure a pool.
:param pool_id: A string that uniquely identifies the Pool within the Account
Expand Down Expand Up @@ -221,7 +221,7 @@ def configure_pool(

def create_pool(self, pool: PoolAddParameter) -> None:
"""
Creates a pool if not already existing.
Create a pool if not already existing.
:param pool: the pool object to create
Expand Down Expand Up @@ -296,7 +296,7 @@ def configure_job(
**kwargs,
) -> JobAddParameter:
"""
Configures a job for use in the pool.
Configure a job for use in the pool.
:param job_id: A string that uniquely identifies the job within the account
:param pool_id: A string that identifies the pool
Expand All @@ -312,7 +312,7 @@ def configure_job(

def create_job(self, job: JobAddParameter) -> None:
"""
Creates a job in the pool.
Create a job in the pool.
:param job: The job object to create
"""
Expand All @@ -334,7 +334,7 @@ def configure_task(
**kwargs,
) -> TaskAddParameter:
"""
Creates a task.
Create a task.
:param task_id: A string that identifies the task to create
:param command_line: The command line of the Task.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def connection(self):

def get_conn(self) -> Any:
"""
Authenticates the resource using the connection id passed during init.
Authenticate the resource using the connection id passed during init.
:return: the authenticated client.
"""
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/microsoft/azure/hooks/container_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AzureContainerRegistryHook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 StringField
Expand All @@ -67,7 +67,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": ["schema", "port", "extra"],
"relabeling": {
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/microsoft/azure/hooks/container_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AzureContainerVolumeHook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 BS3PasswordFieldWidget, BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import PasswordField, StringField
Expand All @@ -67,7 +67,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": ["schema", "port", "host", "extra"],
"relabeling": {
Expand Down
18 changes: 9 additions & 9 deletions airflow/providers/microsoft/azure/hooks/cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

class AzureCosmosDBHook(BaseHook):
"""
Interacts with Azure CosmosDB.
Interact with Azure CosmosDB.
login should be the endpoint uri, password should be the master key
optionally, you can use the following extras to default these values
Expand All @@ -62,7 +62,7 @@ class AzureCosmosDBHook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 StringField
Expand All @@ -86,7 +86,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": ["schema", "port", "host", "extra"],
"relabeling": {
Expand Down Expand Up @@ -180,7 +180,7 @@ def __get_collection_name(self, collection_name: str | None = None) -> str:
return coll_name

def does_collection_exist(self, collection_name: str, database_name: str) -> bool:
"""Checks if a collection exists in CosmosDB."""
"""Check if a collection exists in CosmosDB."""
if collection_name is None:
raise AirflowBadRequest("Collection name cannot be None.")

Expand All @@ -205,7 +205,7 @@ def create_collection(
database_name: str | None = None,
partition_key: str | None = None,
) -> None:
"""Creates a new collection in the CosmosDB database."""
"""Create a new collection in the CosmosDB database."""
if collection_name is None:
raise AirflowBadRequest("Collection name cannot be None.")

Expand All @@ -229,7 +229,7 @@ def create_collection(
)

def does_database_exist(self, database_name: str) -> bool:
"""Checks if a database exists in CosmosDB."""
"""Check if a database exists in CosmosDB."""
if database_name is None:
raise AirflowBadRequest("Database name cannot be None.")

Expand All @@ -247,7 +247,7 @@ def does_database_exist(self, database_name: str) -> bool:
return True

def create_database(self, database_name: str) -> None:
"""Creates a new database in CosmosDB."""
"""Create a new database in CosmosDB."""
if database_name is None:
raise AirflowBadRequest("Database name cannot be None.")

Expand All @@ -267,14 +267,14 @@ def create_database(self, database_name: str) -> None:
self.get_conn().create_database(database_name)

def delete_database(self, database_name: str) -> None:
"""Deletes an existing database in CosmosDB."""
"""Delete an existing database in CosmosDB."""
if database_name is None:
raise AirflowBadRequest("Database name cannot be None.")

self.get_conn().delete_database(database_name)

def delete_collection(self, collection_name: str, database_name: str | None = None) -> None:
"""Deletes an existing collection in the CosmosDB database."""
"""Delete an existing collection in the CosmosDB database."""
if collection_name is None:
raise AirflowBadRequest("Collection name cannot be None.")

Expand Down
6 changes: 3 additions & 3 deletions airflow/providers/microsoft/azure/hooks/data_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class AzureDataFactoryHook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 StringField
Expand All @@ -175,7 +175,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": ["schema", "port", "host", "extra"],
"relabeling": {
Expand Down Expand Up @@ -817,7 +817,7 @@ def wait_for_pipeline_run_status(
timeout: int = 60 * 60 * 24 * 7,
) -> bool:
"""
Waits for a pipeline run to match an expected status.
Wait for a pipeline run to match an expected status.
:param run_id: The pipeline run identifier.
:param expected_statuses: The desired status(es) to check against a pipeline run's current status.
Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/microsoft/azure/hooks/data_lake.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class AzureDataLakeHook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 StringField
Expand All @@ -82,7 +82,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": ["schema", "port", "host", "extra"],
"relabeling": {
Expand Down Expand Up @@ -277,7 +277,7 @@ class AzureDataLakeStorageV2Hook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 BS3PasswordFieldWidget, BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import PasswordField, StringField
Expand All @@ -293,7 +293,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": ["schema", "port"],
"relabeling": {
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/microsoft/azure/hooks/fileshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AzureFileShareHook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 BS3PasswordFieldWidget, BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import PasswordField, StringField
Expand All @@ -59,7 +59,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": ["schema", "port", "host", "extra"],
"relabeling": {
Expand Down
12 changes: 6 additions & 6 deletions airflow/providers/microsoft/azure/hooks/synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class AzureSynapseHook(BaseHook):
@classmethod
@add_managed_identity_connection_widgets
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 StringField
Expand All @@ -84,7 +84,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": ["schema", "port", "extra"],
"relabeling": {
Expand Down Expand Up @@ -179,7 +179,7 @@ def wait_for_job_run_status(
timeout: int = 60 * 60 * 24 * 7,
) -> bool:
"""
Waits for a job run to match an expected status.
Wait for a job run to match an expected status.
:param job_id: The job run identifier.
:param expected_statuses: The desired status(es) to check against a job run's current status.
Expand Down Expand Up @@ -255,7 +255,7 @@ class AzureSynapsePipelineHook(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 StringField
Expand All @@ -266,7 +266,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": ["schema", "port", "extra"],
"relabeling": {"login": "Client ID", "password": "Secret", "host": "Synapse Workspace URL"},
Expand Down Expand Up @@ -362,7 +362,7 @@ def wait_for_pipeline_run_status(
timeout: int = 60 * 60 * 24 * 7,
) -> bool:
"""
Waits for a pipeline run to match an expected status.
Wait for a pipeline run to match an expected status.
:param run_id: The pipeline run identifier.
:param expected_statuses: The desired status(es) to check against a pipeline run's current status.
Expand Down
Loading

0 comments on commit 9d91bb4

Please sign in to comment.