Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Fix mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kaxil committed Aug 25, 2020
1 parent 1940fd8 commit de2cac4
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
)

transfer_config_id = (
"{{ task_instance.xcom_pull('gcp_bigquery_create_transfer', " "key='transfer_config_id') }}"
"{{ task_instance.xcom_pull('gcp_bigquery_create_transfer', key='transfer_config_id') }}"
)
# [END howto_bigquery_create_data_transfer]

Expand Down
16 changes: 8 additions & 8 deletions airflow/providers/google/cloud/hooks/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ def delete_dataset(
)

@GoogleBaseHook.fallback_to_default_project_id
def create_external_table(
self, # pylint: disable=too-many-locals,too-many-arguments
def create_external_table( # pylint: disable=too-many-locals,too-many-arguments
self,
external_project_dataset_table: str,
schema_fields: List,
source_uris: List,
Expand Down Expand Up @@ -717,8 +717,8 @@ def update_table(
return table_object.to_api_repr()

@GoogleBaseHook.fallback_to_default_project_id
def patch_table(
self, # pylint: disable=too-many-arguments
def patch_table( # pylint: disable=too-many-arguments
self,
dataset_id: str,
table_id: str,
project_id: Optional[str] = None,
Expand Down Expand Up @@ -1494,8 +1494,8 @@ def run_with_configuration(self, configuration: Dict) -> str:
self.running_job_id = job.job_id
return job.job_id

def run_load(
self, # pylint: disable=too-many-locals,too-many-arguments,invalid-name
def run_load( # pylint: disable=too-many-locals,too-many-arguments,invalid-name
self,
destination_project_dataset_table: str,
source_uris: List,
schema_fields: Optional[List] = None,
Expand Down Expand Up @@ -1742,8 +1742,8 @@ def run_load(
self.running_job_id = job.job_id
return job.job_id

def run_copy(
self, # pylint: disable=invalid-name
def run_copy( # pylint: disable=invalid-name
self,
source_project_dataset_tables: Union[List, 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 @@ -169,11 +169,9 @@ def create_transfer_job(self, body: Dict) -> Dict:
"""
body = self._inject_project_id(body, BODY, PROJECT_ID)
try:
# pylint: disable=no-member
transfer_job = (
self.get_conn()
.transferJobs()
.create(body=body)
.execute(num_retries=self.num_retries) # pylint: disable=no-member
self.get_conn().transferJobs().create(body=body).execute(num_retries=self.num_retries)
)
except HttpError as e:
# If status code "Conflict"
Expand Down Expand Up @@ -254,9 +252,8 @@ def list_transfer_job(self, request_filter: Optional[Dict] = None, **kwargs) ->
response = request.execute(num_retries=self.num_retries)
jobs.extend(response[TRANSFER_JOBS])

request = conn.transferJobs().list_next(
previous_request=request, previous_response=response # pylint: disable=no-member
)
# pylint: disable=no-member
request = conn.transferJobs().list_next(previous_request=request, previous_response=response)

return jobs

Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/google/cloud/hooks/gdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ def list_deployments(
"""
deployments = [] # type: List[Dict]
conn = self.get_conn()
request = conn.deployments().list(
project=project_id, filter=deployment_filter, orderBy=order_by # pylint: disable=no-member
)
# pylint: disable=no-member
request = conn.deployments().list(project=project_id, filter=deployment_filter, orderBy=order_by)

while request is not None:
response = request.execute(num_retries=self.num_retries)
Expand Down Expand Up @@ -100,8 +99,9 @@ def delete_deployment(
:rtype: None
"""
conn = self.get_conn()
# pylint: disable=no-member
request = conn.deployments().delete(
project=project_id, deployment=deployment, deletePolicy=delete_policy # pylint: disable=no-member
project=project_id, deployment=deployment, deletePolicy=delete_policy
)
resp = request.execute()
if 'error' in resp.keys():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
T = TypeVar("T", bound=Callable) # pylint: disable=invalid-name


def create_evaluate_ops(
task_prefix: str, # pylint: disable=too-many-arguments
def create_evaluate_ops( # pylint: disable=too-many-arguments
task_prefix: str,
data_format: str,
input_paths: List[str],
prediction_path: str,
Expand Down
8 changes: 5 additions & 3 deletions airflow/providers/google/common/hooks/base_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,12 @@ def provide_authorized_gcloud(self):
credentials_path = _cloud_sdk.get_application_default_credentials_path()
project_id = self.project_id

with self.provide_gcp_credential_file_as_context(), tempfile.TemporaryDirectory() as gcloud_config_tmp, patch_environ(
{'CLOUDSDK_CONFIG': gcloud_config_tmp}
):
# fmt: off
with self.provide_gcp_credential_file_as_context(), \
tempfile.TemporaryDirectory() as gcloud_config_tmp, \
patch_environ({'CLOUDSDK_CONFIG': gcloud_config_tmp}):

# fmt: on
if project_id:
# Don't display stdout/stderr for security reason
check_output(["gcloud", "config", "set", "core/project", project_id])
Expand Down
27 changes: 16 additions & 11 deletions airflow/providers/google/suite/hooks/sheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ def get_values(
:rtype: List
"""
service = self.get_conn()
# pylint: disable=no-member
response = (
service.spreadsheets()
.values()
.get( # pylint: disable=no-member
.get(
spreadsheetId=spreadsheet_id,
range=range_,
majorDimension=major_dimension,
Expand Down Expand Up @@ -154,10 +155,11 @@ def batch_get_values(
:rtype: Dict
"""
service = self.get_conn()
# pylint: disable=no-member
response = (
service.spreadsheets()
.values()
.batchGet( # pylint: disable=no-member
.batchGet(
spreadsheetId=spreadsheet_id,
ranges=ranges,
majorDimension=major_dimension,
Expand Down Expand Up @@ -210,10 +212,11 @@ def update_values(
"""
service = self.get_conn()
body = {"range": range_, "majorDimension": major_dimension, "values": values}
# pylint: disable=no-member
response = (
service.spreadsheets()
.values()
.update( # pylint: disable=no-member
.update(
spreadsheetId=spreadsheet_id,
range=range_,
valueInputOption=value_input_option,
Expand Down Expand Up @@ -286,10 +289,11 @@ def batch_update_values(
"responseValueRenderOption": value_render_option,
"responseDateTimeRenderOption": date_time_render_option,
}
# pylint: disable=no-member
response = (
service.spreadsheets()
.values()
.batchUpdate(spreadsheetId=spreadsheet_id, body=body) # pylint: disable=no-member
.batchUpdate(spreadsheetId=spreadsheet_id, body=body)
.execute(num_retries=self.num_retries)
)

Expand Down Expand Up @@ -340,10 +344,11 @@ def append_values(
"""
service = self.get_conn()
body = {"range": range_, "majorDimension": major_dimension, "values": values}
# pylint: disable=no-member
response = (
service.spreadsheets()
.values()
.append( # pylint: disable=no-member
.append(
spreadsheetId=spreadsheet_id,
range=range_,
valueInputOption=value_input_option,
Expand Down Expand Up @@ -371,10 +376,11 @@ def clear(self, spreadsheet_id: str, range_: str) -> Dict:
:rtype: Dict
"""
service = self.get_conn()
# pylint: disable=no-member
response = (
service.spreadsheets()
.values()
.clear(spreadsheetId=spreadsheet_id, range=range_) # pylint: disable=no-member
.clear(spreadsheetId=spreadsheet_id, range=range_)
.execute(num_retries=self.num_retries)
)

Expand All @@ -394,10 +400,11 @@ def batch_clear(self, spreadsheet_id: str, ranges: List) -> Dict:
"""
service = self.get_conn()
body = {"ranges": ranges}
# pylint: disable=no-member
response = (
service.spreadsheets()
.values()
.batchClear(spreadsheetId=spreadsheet_id, body=body) # pylint: disable=no-member
.batchClear(spreadsheetId=spreadsheet_id, body=body)
.execute(num_retries=self.num_retries)
)

Expand Down Expand Up @@ -452,11 +459,9 @@ def create_spreadsheet(self, spreadsheet: Dict[str, Any]) -> Dict[str, Any]:
:return: An spreadsheet object.
"""
self.log.info("Creating spreadsheet: %s", spreadsheet['properties']['title'])
# pylint: disable=no-member
response = (
self.get_conn() # pylint: disable=no-member
.spreadsheets()
.create(body=spreadsheet)
.execute(num_retries=self.num_retries)
self.get_conn().spreadsheets().create(body=spreadsheet).execute(num_retries=self.num_retries)
)
self.log.info("Spreadsheet: %s created", spreadsheet['properties']['title'])
return response
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
SNOWFLAKE_SELECT_SQL = f"SELECT * FROM {SNOWFLAKE_SAMPLE_TABLE} LIMIT 100;"
SNOWFLAKE_SLACK_SQL = f"SELECT O_ORDERKEY, O_CUSTKEY, O_ORDERSTATUS FROM {SNOWFLAKE_SAMPLE_TABLE} LIMIT 10;"
SNOWFLAKE_SLACK_MESSAGE = (
"Results in an ASCII table:\n" "```{{ results_df | tabulate(tablefmt='pretty', headers='keys') }}```"
"Results in an ASCII table:\n```{{ results_df | tabulate(tablefmt='pretty', headers='keys') }}```"
)
SNOWFLAKE_CREATE_TABLE_SQL = f"CREATE TRANSIENT TABLE IF NOT EXISTS {SNOWFLAKE_LOAD_TABLE}(data VARIANT);"

Expand Down
2 changes: 1 addition & 1 deletion tests/providers/amazon/aws/log/test_s3_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_read(self):
self.assertEqual(
self.s3_task_handler.read(self.ti),
(
['*** Reading remote log from s3://bucket/remote/log/location/1.log.\n' 'Log line\n\n'],
['*** Reading remote log from s3://bucket/remote/log/location/1.log.\nLog line\n\n'],
[{'end_of_log': True}],
),
)
Expand Down
11 changes: 7 additions & 4 deletions tests/providers/amazon/aws/operators/test_ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,28 @@
from airflow.exceptions import AirflowException
from airflow.providers.amazon.aws.operators.ecs import ECSOperator

# fmt: off
RESPONSE_WITHOUT_FAILURES = {
"failures": [],
"tasks": [
{
"containers": [
{
"containerArn": "arn:aws:ecs:us-east-1:012345678910:container/e1ed7aac-d9b2-4315-8726-d2432bf11868",
"containerArn":
"arn:aws:ecs:us-east-1:012345678910:container/e1ed7aac-d9b2-4315-8726-d2432bf11868",
"lastStatus": "PENDING",
"name": "wordpress",
"taskArn": "arn:aws:ecs:us-east-1:012345678910:task/d8c67b3c-ac87-4ffe-a847-4785bc3a8b55",
"taskArn": "arn:aws:ecs:us-east-1:012345678910:task/d8c67b3c-ac87-4ffe-a847-4785bc3a8b55"
}
],
"desiredStatus": "RUNNING",
"lastStatus": "PENDING",
"taskArn": "arn:aws:ecs:us-east-1:012345678910:task/d8c67b3c-ac87-4ffe-a847-4785bc3a8b55",
"taskDefinitionArn": "arn:aws:ecs:us-east-1:012345678910:task-definition/hello_world:11",
"taskDefinitionArn": "arn:aws:ecs:us-east-1:012345678910:task-definition/hello_world:11"
}
],
]
}
# fmt: on


class TestECSOperator(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/apache/spark/hooks/test_spark_jdbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def test_build_jdbc_arguments(self):
'-saveFormat',
'parquet',
'-createTableColumnTypes',
'columnMcColumnFace INTEGER(100), name CHAR(64),' 'comments VARCHAR(1024)',
'columnMcColumnFace INTEGER(100), name CHAR(64), comments VARCHAR(1024)',
]
self.assertEqual(expected_jdbc_arguments, cmd)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class TestSparkJDBCScrip:
'-upperBound',
'20',
'-createTableColumnTypes',
'columnMcColumnFace INTEGER(100), name CHAR(64),' 'comments VARCHAR(1024)',
'columnMcColumnFace INTEGER(100), name CHAR(64), comments VARCHAR(1024)',
]

default_arguments = {
Expand Down
Loading

0 comments on commit de2cac4

Please sign in to comment.