Skip to content

Commit

Permalink
Use Python 3 style super classes (#11806)
Browse files Browse the repository at this point in the history
example:

```
super().__init__(label, validators, **kwargs)
```

instead of
```
super(DateTimeWithTimezoneField, self).__init__(label, validators, **kwargs)
```
  • Loading branch information
kaxil authored Oct 24, 2020
1 parent 6ca933b commit 4830687
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions airflow/api_connexion/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class NotFound(ProblemException):
def __init__(
self, title: str = 'Not Found', detail: Optional[str] = None, headers: Optional[Dict] = None, **kwargs
):
super(NotFound, self).__init__(
super().__init__(
status=404, type=EXCEPTIONS_LINK_MAP[404], title=title, detail=detail, headers=headers, **kwargs
)

Expand All @@ -93,7 +93,7 @@ def __init__(
headers: Optional[Dict] = None,
**kwargs,
):
super(BadRequest, self).__init__(
super().__init__(
status=400, type=EXCEPTIONS_LINK_MAP[400], title=title, detail=detail, headers=headers, **kwargs
)

Expand All @@ -108,7 +108,7 @@ def __init__(
headers: Optional[Dict] = None,
**kwargs,
):
super(Unauthenticated, self).__init__(
super().__init__(
status=401, type=EXCEPTIONS_LINK_MAP[401], title=title, detail=detail, headers=headers, **kwargs
)

Expand All @@ -119,7 +119,7 @@ class PermissionDenied(ProblemException):
def __init__(
self, title: str = 'Forbidden', detail: Optional[str] = None, headers: Optional[Dict] = None, **kwargs
):
super(PermissionDenied, self).__init__(
super().__init__(
status=403, type=EXCEPTIONS_LINK_MAP[403], title=title, detail=detail, headers=headers, **kwargs
)

Expand All @@ -130,7 +130,7 @@ class AlreadyExists(ProblemException):
def __init__(
self, title='Conflict', detail: Optional[str] = None, headers: Optional[Dict] = None, **kwargs
):
super(AlreadyExists, self).__init__(
super().__init__(
status=409, type=EXCEPTIONS_LINK_MAP[409], title=title, detail=detail, headers=headers, **kwargs
)

Expand All @@ -145,6 +145,6 @@ def __init__(
headers: Optional[Dict] = None,
**kwargs,
):
super(Unknown, self).__init__(
super().__init__(
status=500, type=EXCEPTIONS_LINK_MAP[500], title=title, detail=detail, headers=headers, **kwargs
)
2 changes: 1 addition & 1 deletion airflow/providers/amazon/aws/operators/glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
iam_role_name: Optional[str] = None,
**kwargs,
): # pylint: disable=too-many-arguments
super(AwsGlueJobOperator, self).__init__(**kwargs)
super().__init__(**kwargs)
self.job_name = job_name
self.job_desc = job_desc
self.script_location = script_location
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/apache/livy/hooks/livy.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class LivyHook(HttpHook, LoggingMixin):
_def_headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}

def __init__(self, livy_conn_id: str = 'livy_default') -> None:
super(LivyHook, self).__init__(http_conn_id=livy_conn_id)
super().__init__(http_conn_id=livy_conn_id)

def get_conn(self, headers: Optional[Dict[str, Any]] = None) -> Any:
"""
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/exasol/hooks/exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ExasolHook(DbApiHook):
supports_autocommit = True

def __init__(self, *args, **kwargs) -> None:
super(ExasolHook, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.schema = kwargs.pop("schema", None)

def get_conn(self) -> ExaConnection:
Expand Down Expand Up @@ -167,7 +167,7 @@ def get_autocommit(self, conn) -> bool:
"""
autocommit = conn.attr.get('autocommit')
if autocommit is None:
autocommit = super(ExasolHook, self).get_autocommit(conn)
autocommit = super().get_autocommit(conn)
return autocommit

@staticmethod
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 @@ -56,7 +56,7 @@ def __init__(
schema: Optional[str] = None,
**kwargs,
) -> None:
super(ExasolOperator, self).__init__(**kwargs)
super().__init__(**kwargs)
self.exasol_conn_id = exasol_conn_id
self.sql = sql
self.autocommit = autocommit
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/hooks/gdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(
delegate_to: Optional[str] = None,
impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
) -> None:
super(GoogleDeploymentManagerHook, self).__init__(
super().__init__(
gcp_conn_id=gcp_conn_id,
delegate_to=delegate_to,
impersonation_chain=impersonation_chain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def __init__(
impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
**kwargs,
) -> None:
super(GoogleAnalyticsModifyFileHeadersDataImportOperator, self).__init__(**kwargs)
super().__init__(**kwargs)
self.storage_bucket = storage_bucket
self.storage_name_object = storage_name_object
self.gcp_conn_id = gcp_conn_id
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/singularity/operators/singularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__( # pylint: disable=too-many-arguments
**kwargs,
) -> None:

super(SingularityOperator, self).__init__(**kwargs)
super().__init__(**kwargs)
self.auto_remove = auto_remove
self.command = command
self.start_command = start_command
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/slack/operators/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def __init__(
self.filename = filename
self.filetype = filetype
self.content = content
super(SlackAPIFileOperator, self).__init__(method=self.method, **kwargs)
super().__init__(method=self.method, **kwargs)

def construct_api_call_params(self) -> Any:
self.api_params = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__( # pylint: disable=too-many-arguments
slack_token: Optional[str] = None,
**kwargs,
) -> None:
super(SnowflakeToSlackOperator, self).__init__(**kwargs)
super().__init__(**kwargs)

self.snowflake_conn_id = snowflake_conn_id
self.sql = sql
Expand Down
2 changes: 1 addition & 1 deletion airflow/www/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DateTimeWithTimezoneField(Field):
widget = widgets.TextInput()

def __init__(self, label=None, validators=None, datetime_format='%Y-%m-%d %H:%M:%S%Z', **kwargs):
super(DateTimeWithTimezoneField, self).__init__(label, validators, **kwargs)
super().__init__(label, validators, **kwargs)
self.format = datetime_format
self.data = None

Expand Down

0 comments on commit 4830687

Please sign in to comment.