Skip to content

Commit

Permalink
Add correct signature to all operators and sensors (#10205)
Browse files Browse the repository at this point in the history
* add correct signature to operators in providers package

* add keyword only to operators and sensors outside provider package

* remove unused type ignore
  • Loading branch information
ephraimbuddy committed Aug 6, 2020
1 parent c920b1b commit cdec301
Show file tree
Hide file tree
Showing 104 changed files with 122 additions and 114 deletions.
4 changes: 2 additions & 2 deletions airflow/operators/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class EmailOperator(BaseOperator):
ui_color = '#e6faf9'

@apply_defaults
def __init__(
self,
def __init__( # pylint: disable=invalid-name
self, *,
to: Union[List[str], str],
subject: str,
html_content: str,
Expand Down
8 changes: 4 additions & 4 deletions airflow/operators/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class SQLValueCheckOperator(BaseOperator):

@apply_defaults
def __init__(
self,
self, *,
sql: str,
pass_value: Any,
tolerance: Any = None,
Expand Down Expand Up @@ -271,7 +271,7 @@ class SQLIntervalCheckOperator(BaseOperator):

@apply_defaults
def __init__(
self,
self, *,
table: str,
metrics_thresholds: Dict[str, int],
date_filter_column: Optional[str] = "ds",
Expand Down Expand Up @@ -415,7 +415,7 @@ class SQLThresholdCheckOperator(BaseOperator):

@apply_defaults
def __init__(
self,
self, *,
sql: str,
min_threshold: Any,
max_threshold: Any,
Expand Down Expand Up @@ -507,7 +507,7 @@ class BranchSQLOperator(BaseOperator, SkipMixin):

@apply_defaults
def __init__(
self,
self, *,
sql: str,
follow_task_ids_if_true: List[str],
follow_task_ids_if_false: List[str],
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/celery/sensors/celery_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CeleryQueueSensor(BaseSensorOperator):
"""
@apply_defaults
def __init__(
self,
self, *,
celery_queue: str,
target_task_id: Optional[str] = None,
**kwargs) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class KubernetesPodOperator(BaseOperator): # pylint: disable=too-many-instance-

@apply_defaults
def __init__(self, # pylint: disable=too-many-arguments,too-many-locals
*,
namespace: Optional[str] = None,
image: Optional[str] = None,
name: Optional[str] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SparkKubernetesOperator(BaseOperator):
ui_color = '#f4a460'

@apply_defaults
def __init__(self,
def __init__(self, *,
application_file: str,
namespace: Optional[str] = None,
kubernetes_conn_id: str = 'kubernetes_default',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SparkKubernetesSensor(BaseSensorOperator):
SUCCESS_STATES = ('COMPLETED',)

@apply_defaults
def __init__(self,
def __init__(self, *,
application_name: str,
namespace: Optional[str] = None,
kubernetes_conn_id: str = 'kubernetes_default',
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/databricks/operators/databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class DatabricksSubmitRunOperator(BaseOperator):
# pylint: disable=too-many-arguments
@apply_defaults
def __init__(
self,
self, *,
json=None,
spark_jar_task=None,
notebook_task=None,
Expand Down Expand Up @@ -457,7 +457,7 @@ class DatabricksRunNowOperator(BaseOperator):
# pylint: disable=too-many-arguments
@apply_defaults
def __init__(
self,
self, *,
job_id=None,
json=None,
notebook_params=None,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/datadog/sensors/datadog.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DatadogSensor(BaseSensorOperator):

@apply_defaults
def __init__(
self,
self, *,
datadog_conn_id: str = 'datadog_default',
from_seconds_ago: int = 3600,
up_to_seconds_from_now: int = 0,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/dingding/operators/dingding.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DingdingOperator(BaseOperator):
ui_color = '#4ea4d4' # Dingding icon color

@apply_defaults
def __init__(self,
def __init__(self, *,
dingding_conn_id='dingding_default',
message_type='text',
message=None,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/discord/operators/discord_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DiscordWebhookOperator(SimpleHttpOperator):
template_fields = ['username', 'message']

@apply_defaults
def __init__(self,
def __init__(self, *,
http_conn_id: Optional[str] = None,
webhook_endpoint: Optional[str] = None,
message: str = "",
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/docker/operators/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class DockerOperator(BaseOperator):
# pylint: disable=too-many-arguments,too-many-locals
@apply_defaults
def __init__(
self,
self, *,
image: str,
api_version: Optional[str] = None,
command: Optional[Union[str, List[str]]] = None,
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/docker/operators/docker_swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ class DockerSwarmOperator(DockerOperator):
@apply_defaults
def __init__(
self,
*,
image: str,
enable_logging: bool = True,
*args,
**kwargs) -> None:
super().__init__(image=image, *args, **kwargs) # type: ignore
super().__init__(image=image, **kwargs)

self.enable_logging = enable_logging
self.service = None
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/exasol/operators/exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ExasolOperator(BaseOperator):

@apply_defaults
def __init__(
self,
self, *,
sql: str,
exasol_conn_id: str = 'exasol_default',
autocommit: bool = False,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/ftp/sensors/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FTPSensor(BaseSensorOperator):

@apply_defaults
def __init__(
self,
self, *,
path: str,
ftp_conn_id: str = 'ftp_default',
fail_on_transient_errors: bool = True,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/ads/transfers/ads_to_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class GoogleAdsToGcsOperator(BaseOperator):

@apply_defaults
def __init__(
self,
self, *,
client_ids: List[str],
query: str,
attributes: List[str],
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/sensors/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class BigQueryTableExistenceSensor(BaseSensorOperator):
ui_color = '#f0eee4'

@apply_defaults
def __init__(self,
def __init__(self, *,
project_id: str,
dataset_id: str,
table_id: str,
Expand Down
1 change: 1 addition & 0 deletions airflow/providers/google/cloud/sensors/bigquery_dts.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class BigQueryDataTransferServiceTransferRunSensor(BaseSensorOperator):
@apply_defaults
def __init__(
self,
*,
run_id: str,
transfer_config_id: str,
expected_statuses: Union[Set[str], str] = 'SUCCEEDED',
Expand Down
1 change: 1 addition & 0 deletions airflow/providers/google/cloud/sensors/bigtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class BigtableTableReplicationCompletedSensor(BaseSensorOperator, BigtableValida
@apply_defaults
def __init__(
self,
*,
instance_id: str,
table_id: str,
project_id: Optional[str] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CloudDataTransferServiceJobStatusSensor(BaseSensorOperator):

@apply_defaults
def __init__(
self,
self, *,
job_name: str,
expected_statuses: Union[Set[str], str],
project_id: Optional[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/sensors/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class GCSObjectExistenceSensor(BaseSensorOperator):
ui_color = '#f0eee4'

@apply_defaults
def __init__(self,
def __init__(self, *,
bucket: str,
object: str, # pylint: disable=redefined-builtin
google_cloud_conn_id: str = 'google_cloud_default',
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/sensors/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class PubSubPullSensor(BaseSensorOperator):

@apply_defaults
def __init__(
self,
self, *,
project_id: str,
subscription: str,
max_messages: int = 5,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/transfers/adls_to_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ADLSToGCSOperator(AzureDataLakeStorageListOperator):
ui_color = '#f0eee4'

@apply_defaults
def __init__(self,
def __init__(self, *,
src_adls: str,
dest_gcs: str,
azure_data_lake_conn_id: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class BigQueryToBigQueryOperator(BaseOperator):
ui_color = '#e6f0e4'

@apply_defaults
def __init__(self, # pylint: disable=too-many-arguments
def __init__(self, *, # pylint: disable=too-many-arguments
source_project_dataset_tables: Union[List[str], str],
destination_project_dataset_table: str,
write_disposition: str = 'WRITE_EMPTY',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class BigQueryToGCSOperator(BaseOperator):
ui_color = '#e4e6f0'

@apply_defaults
def __init__(self, # pylint: disable=too-many-arguments
def __init__(self, *, # pylint: disable=too-many-arguments
source_project_dataset_table: str,
destination_cloud_storage_uris: List[str],
compression: str = 'NONE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class BigQueryToMySqlOperator(BaseOperator):
template_fields = ('dataset_id', 'table_id', 'mysql_table')

@apply_defaults
def __init__(self, # pylint: disable=too-many-arguments
def __init__(self, *, # pylint: disable=too-many-arguments
dataset_table: str,
mysql_table: str,
selected_fields: Optional[str] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CassandraToGCSOperator(BaseOperator):
ui_color = '#a0e08c'

@apply_defaults
def __init__(self, # pylint: disable=too-many-arguments
def __init__(self, *, # pylint: disable=too-many-arguments
cql: str,
bucket: str,
filename: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class FacebookAdsReportToGcsOperator(BaseOperator):

@apply_defaults
def __init__(
self,
self, *,
bucket_name: str,
object_name: str,
fields: List[str],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class GCSToBigQueryOperator(BaseOperator):

# pylint: disable=too-many-locals,too-many-arguments
@apply_defaults
def __init__(self,
def __init__(self, *,
bucket,
source_objects,
destination_project_dataset_table,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/transfers/gcs_to_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class GCSToGCSOperator(BaseOperator):
ui_color = '#f0eee4'

@apply_defaults
def __init__(self, # pylint: disable=too-many-arguments
def __init__(self, *, # pylint: disable=too-many-arguments
source_bucket,
source_object=None,
source_objects=None,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/transfers/gcs_to_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class GCSToLocalFilesystemOperator(BaseOperator):
ui_color = '#f0eee4'

@apply_defaults
def __init__(self,
def __init__(self, *,
bucket: str,
object_name: Optional[str] = None,
filename: Optional[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/transfers/gcs_to_sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class GCSToSFTPOperator(BaseOperator):
# pylint: disable=too-many-arguments
@apply_defaults
def __init__(
self,
self, *,
source_bucket: str,
source_object: str,
destination_path: str,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/transfers/local_to_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class LocalFilesystemToGCSOperator(BaseOperator):
template_fields = ('src', 'dst', 'bucket')

@apply_defaults
def __init__(self,
def __init__(self, *,
src,
dst,
bucket,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/transfers/mssql_to_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MSSQLToGCSOperator(BaseSQLToGCSOperator):
}

@apply_defaults
def __init__(self,
def __init__(self, *,
mssql_conn_id='mssql_default',
**kwargs):
super().__init__(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/transfers/mysql_to_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MySQLToGCSOperator(BaseSQLToGCSOperator):
}

@apply_defaults
def __init__(self,
def __init__(self, *,
mysql_conn_id='mysql_default',
ensure_utc=False,
**kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PostgresToGCSOperator(BaseSQLToGCSOperator):
}

@apply_defaults
def __init__(self,
def __init__(self, *,
postgres_conn_id='postgres_default',
**kwargs):
super().__init__(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/transfers/presto_to_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class PrestoToGCSOperator(BaseSQLToGCSOperator):

@apply_defaults
def __init__(
self,
self, *,
presto_conn_id: str = "presto_default",
**kwargs
):
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/transfers/s3_to_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class S3ToGCSOperator(S3ListOperator):

# pylint: disable=too-many-arguments
@apply_defaults
def __init__(self,
def __init__(self, *,
bucket,
prefix='',
delimiter='',
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/transfers/sftp_to_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SFTPToGCSOperator(BaseOperator):

@apply_defaults
def __init__(
self,
self, *,
source_path: str,
destination_bucket: str,
destination_path: Optional[str] = None,
Expand Down

0 comments on commit cdec301

Please sign in to comment.