Skip to content

Commit

Permalink
fixup! Switch to f-strings using flynt. (#13732)
Browse files Browse the repository at this point in the history
  • Loading branch information
potiuk committed Mar 3, 2021
1 parent 9ecee99 commit b05faa4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
18 changes: 7 additions & 11 deletions airflow/providers/snowflake/transfers/s3_to_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,11 @@ def execute(self, context: Any) -> None:
files = files.replace(']', ')')

# we can extend this based on stage
base_sql = """
FROM @{stage}/
base_sql = f"""
FROM @{self.stage}/
files={files}
file_format={file_format}
""".format(
stage=self.stage, files=files, file_format=self.file_format
)
file_format={self.file_format}
"""

if self.columns_array:
copy_query = """
Expand All @@ -97,11 +95,9 @@ def execute(self, context: Any) -> None:
schema=self.schema, table=self.table, columns=",".join(self.columns_array), base_sql=base_sql
)
else:
copy_query = """
COPY INTO {schema}.{table} {base_sql}
""".format(
schema=self.schema, table=self.table, base_sql=base_sql
)
copy_query = f"""
COPY INTO {self.schema}.{self.table} {base_sql}
"""

self.log.info('Executing COPY command...')
snowflake_hook.run(copy_query, self.autocommit)
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/google/cloud/operators/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class TestPubSubPullOperator(unittest.TestCase):
def _generate_messages(self, count):
return [
ReceivedMessage(
ack_id="%s" % i,
ack_id=f"{i}",
message={
"data": f'Message {i}'.encode('utf8'),
"attributes": {"type": "generated message"},
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/google/cloud/sensors/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TestPubSubPullSensor(unittest.TestCase):
def _generate_messages(self, count):
return [
ReceivedMessage(
ack_id="%s" % i,
ack_id=f"{i}",
message={
"data": f'Message {i}'.encode('utf8'),
"attributes": {"type": "generated message"},
Expand Down
18 changes: 6 additions & 12 deletions tests/providers/snowflake/transfers/test_s3_to_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,15 @@ def test_execute(self, mock_run):
files = str(s3_keys)
files = files.replace('[', '(')
files = files.replace(']', ')')
base_sql = """
base_sql = f"""
FROM @{stage}/
files={files}
file_format={file_format}
""".format(
stage=stage, files=files, file_format=file_format
)
"""

copy_query = """
copy_query = f"""
COPY INTO {schema}.{table} {base_sql}
""".format(
schema=schema, table=table, base_sql=base_sql
)
"""

assert mock_run.call_count == 1
assert_equal_ignore_multiple_spaces(self, mock_run.call_args[0][0], copy_query)
Expand Down Expand Up @@ -86,13 +82,11 @@ def test_execute_with_columns(self, mock_run):
files = str(s3_keys)
files = files.replace('[', '(')
files = files.replace(']', ')')
base_sql = """
base_sql = f"""
FROM @{stage}/
files={files}
file_format={file_format}
""".format(
stage=stage, files=files, file_format=file_format
)
"""

copy_query = """
COPY INTO {schema}.{table}({columns}) {base_sql}
Expand Down

0 comments on commit b05faa4

Please sign in to comment.