Skip to content

Commit d56e7b5

Browse files
authored
Fix template_fields type to have MyPy friendly Sequence type (#20571)
Part of #19891
1 parent bd9e8ce commit d56e7b5

File tree

225 files changed

+818
-766
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+818
-766
lines changed

β€Žairflow/providers/airbyte/operators/airbyte.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
from typing import TYPE_CHECKING, Optional
18+
from typing import TYPE_CHECKING, Optional, Sequence
1919

2020
from airflow.models import BaseOperator
2121
from airflow.providers.airbyte.hooks.airbyte import AirbyteHook
@@ -51,7 +51,7 @@ class AirbyteTriggerSyncOperator(BaseOperator):
5151
:type timeout: float
5252
"""
5353

54-
template_fields = ('connection_id',)
54+
template_fields: Sequence[str] = ('connection_id',)
5555

5656
def __init__(
5757
self,

β€Žairflow/providers/airbyte/sensors/airbyte.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# specific language governing permissions and limitations
1717
# under the License.
1818
"""This module contains a Airbyte Job sensor."""
19-
from typing import TYPE_CHECKING
19+
from typing import TYPE_CHECKING, Sequence
2020

2121
from airflow.exceptions import AirflowException
2222
from airflow.providers.airbyte.hooks.airbyte import AirbyteHook
@@ -39,7 +39,7 @@ class AirbyteJobSensor(BaseSensorOperator):
3939
:type api_version: str
4040
"""
4141

42-
template_fields = ('airbyte_job_id',)
42+
template_fields: Sequence[str] = ('airbyte_job_id',)
4343
ui_color = '#6C51FD'
4444

4545
def __init__(

β€Žairflow/providers/alibaba/cloud/sensors/oss_key.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
else:
2323
from cached_property import cached_property
2424

25-
from typing import TYPE_CHECKING, Optional
25+
from typing import TYPE_CHECKING, Optional, Sequence
2626
from urllib.parse import urlparse
2727

2828
from airflow.exceptions import AirflowException
@@ -51,7 +51,7 @@ class OSSKeySensor(BaseSensorOperator):
5151
:type oss_conn_id: Optional[str]
5252
"""
5353

54-
template_fields = ('bucket_key', 'bucket_name')
54+
template_fields: Sequence[str] = ('bucket_key', 'bucket_name')
5555

5656
def __init__(
5757
self,

β€Žairflow/providers/amazon/aws/operators/athena.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919
import sys
2020
import warnings
21-
from typing import TYPE_CHECKING, Any, Dict, Optional
21+
from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence
2222
from uuid import uuid4
2323

2424
if sys.version_info >= (3, 8):
@@ -64,7 +64,7 @@ class AthenaOperator(BaseOperator):
6464
"""
6565

6666
ui_color = '#44b5e2'
67-
template_fields = ('query', 'database', 'output_location')
67+
template_fields: Sequence[str] = ('query', 'database', 'output_location')
6868
template_ext = ('.sql',)
6969
template_fields_renderers = {"query": "sql"}
7070

β€Žairflow/providers/amazon/aws/operators/batch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
- http://boto3.readthedocs.io/en/latest/reference/services/batch.html
2727
- https://docs.aws.amazon.com/batch/latest/APIReference/Welcome.html
2828
"""
29-
from typing import TYPE_CHECKING, Any, Optional
29+
from typing import TYPE_CHECKING, Any, Optional, Sequence
3030

3131
from airflow.exceptions import AirflowException
3232
from airflow.models import BaseOperator
@@ -97,7 +97,7 @@ class AwsBatchOperator(BaseOperator):
9797

9898
ui_color = "#c3dae0"
9999
arn = None # type: Optional[str]
100-
template_fields = (
100+
template_fields: Sequence[str] = (
101101
"job_name",
102102
"overrides",
103103
"parameters",

β€Žairflow/providers/amazon/aws/operators/cloud_formation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# specific language governing permissions and limitations
1717
# under the License.
1818
"""This module contains CloudFormation create/delete stack operators."""
19-
from typing import TYPE_CHECKING, List, Optional
19+
from typing import TYPE_CHECKING, Optional, Sequence
2020

2121
from airflow.models import BaseOperator
2222
from airflow.providers.amazon.aws.hooks.cloud_formation import CloudFormationHook
@@ -40,7 +40,7 @@ class CloudFormationCreateStackOperator(BaseOperator):
4040
:type aws_conn_id: str
4141
"""
4242

43-
template_fields: List[str] = ['stack_name']
43+
template_fields: Sequence[str] = ('stack_name',)
4444
template_ext = ()
4545
ui_color = '#6b9659'
4646

@@ -72,7 +72,7 @@ class CloudFormationDeleteStackOperator(BaseOperator):
7272
:type aws_conn_id: str
7373
"""
7474

75-
template_fields: List[str] = ['stack_name']
75+
template_fields: Sequence[str] = ('stack_name',)
7676
template_ext = ()
7777
ui_color = '#1d472b'
7878
ui_fgcolor = '#FFF'

β€Žairflow/providers/amazon/aws/operators/datasync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import logging
2121
import random
2222
import warnings
23-
from typing import TYPE_CHECKING, List, Optional
23+
from typing import TYPE_CHECKING, List, Optional, Sequence
2424

2525
from airflow.exceptions import AirflowException, AirflowTaskTimeout
2626
from airflow.models import BaseOperator
@@ -111,7 +111,7 @@ class DataSyncOperator(BaseOperator):
111111
:raises AirflowException: If Task creation, update, execution or delete fails.
112112
"""
113113

114-
template_fields = (
114+
template_fields: Sequence[str] = (
115115
"task_arn",
116116
"source_location_uri",
117117
"destination_location_uri",

β€Žairflow/providers/amazon/aws/operators/dms.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# under the License.
1818

1919

20-
from typing import TYPE_CHECKING, Dict, Optional
20+
from typing import TYPE_CHECKING, Dict, Optional, Sequence
2121

2222
from airflow.models import BaseOperator
2323
from airflow.providers.amazon.aws.hooks.dms import DmsHook
@@ -56,7 +56,7 @@ class DmsCreateTaskOperator(BaseOperator):
5656
:type aws_conn_id: Optional[str]
5757
"""
5858

59-
template_fields = (
59+
template_fields: Sequence[str] = (
6060
'replication_task_id',
6161
'source_endpoint_arn',
6262
'target_endpoint_arn',
@@ -134,7 +134,7 @@ class DmsDeleteTaskOperator(BaseOperator):
134134
:type aws_conn_id: Optional[str]
135135
"""
136136

137-
template_fields = ('replication_task_arn',)
137+
template_fields: Sequence[str] = ('replication_task_arn',)
138138
template_ext = ()
139139
template_fields_renderers: Dict[str, str] = {}
140140

@@ -174,7 +174,7 @@ class DmsDescribeTasksOperator(BaseOperator):
174174
:type aws_conn_id: Optional[str]
175175
"""
176176

177-
template_fields = ('describe_tasks_kwargs',)
177+
template_fields: Sequence[str] = ('describe_tasks_kwargs',)
178178
template_ext = ()
179179
template_fields_renderers: Dict[str, str] = {'describe_tasks_kwargs': 'json'}
180180

@@ -223,7 +223,7 @@ class DmsStartTaskOperator(BaseOperator):
223223
:type aws_conn_id: Optional[str]
224224
"""
225225

226-
template_fields = (
226+
template_fields: Sequence[str] = (
227227
'replication_task_arn',
228228
'start_replication_task_type',
229229
'start_task_kwargs',
@@ -276,7 +276,7 @@ class DmsStopTaskOperator(BaseOperator):
276276
:type aws_conn_id: Optional[str]
277277
"""
278278

279-
template_fields = ('replication_task_arn',)
279+
template_fields: Sequence[str] = ('replication_task_arn',)
280280
template_ext = ()
281281
template_fields_renderers: Dict[str, str] = {}
282282

β€Žairflow/providers/amazon/aws/operators/ec2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# under the License.
1818
#
1919

20-
from typing import TYPE_CHECKING, Optional
20+
from typing import TYPE_CHECKING, Optional, Sequence
2121

2222
from airflow.models import BaseOperator
2323
from airflow.providers.amazon.aws.hooks.ec2 import EC2Hook
@@ -41,7 +41,7 @@ class EC2StartInstanceOperator(BaseOperator):
4141
:type check_interval: float
4242
"""
4343

44-
template_fields = ("instance_id", "region_name")
44+
template_fields: Sequence[str] = ("instance_id", "region_name")
4545
ui_color = "#eeaa11"
4646
ui_fgcolor = "#ffffff"
4747

@@ -87,7 +87,7 @@ class EC2StopInstanceOperator(BaseOperator):
8787
:type check_interval: float
8888
"""
8989

90-
template_fields = ("instance_id", "region_name")
90+
template_fields: Sequence[str] = ("instance_id", "region_name")
9191
ui_color = "#eeaa11"
9292
ui_fgcolor = "#ffffff"
9393

β€Žairflow/providers/amazon/aws/operators/ecs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from datetime import datetime, timedelta
2323
from logging import Logger
2424
from threading import Event, Thread
25-
from typing import Dict, Generator, Optional
25+
from typing import Dict, Generator, Optional, Sequence
2626

2727
from botocore.exceptions import ClientError
2828
from botocore.waiter import Waiter
@@ -225,7 +225,7 @@ class ECSOperator(BaseOperator):
225225
"""
226226

227227
ui_color = '#f0ede4'
228-
template_fields = ('overrides',)
228+
template_fields: Sequence[str] = ('overrides',)
229229
template_fields_renderers = {
230230
"overrides": "json",
231231
"network_configuration": "json",

0 commit comments

Comments
 (0)