You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/03/03 09:33:03 UTC
[airflow] 39/41: fixup! Switch to f-strings using flynt. (#13732)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v2-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
commit b05faa4c8ad979375d93c472cdb72628801a0ede
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Wed Mar 3 06:06:41 2021 +0100
fixup! Switch to f-strings using flynt. (#13732)
---
.../providers/snowflake/transfers/s3_to_snowflake.py | 18 +++++++-----------
tests/providers/google/cloud/operators/test_pubsub.py | 2 +-
tests/providers/google/cloud/sensors/test_pubsub.py | 2 +-
.../snowflake/transfers/test_s3_to_snowflake.py | 18 ++++++------------
4 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/airflow/providers/snowflake/transfers/s3_to_snowflake.py b/airflow/providers/snowflake/transfers/s3_to_snowflake.py
index 2238718..27f8810 100644
--- a/airflow/providers/snowflake/transfers/s3_to_snowflake.py
+++ b/airflow/providers/snowflake/transfers/s3_to_snowflake.py
@@ -82,13 +82,11 @@ class S3ToSnowflakeOperator(BaseOperator):
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 = """
@@ -97,11 +95,9 @@ class S3ToSnowflakeOperator(BaseOperator):
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)
diff --git a/tests/providers/google/cloud/operators/test_pubsub.py b/tests/providers/google/cloud/operators/test_pubsub.py
index 6abfffa..02f356d 100644
--- a/tests/providers/google/cloud/operators/test_pubsub.py
+++ b/tests/providers/google/cloud/operators/test_pubsub.py
@@ -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"},
diff --git a/tests/providers/google/cloud/sensors/test_pubsub.py b/tests/providers/google/cloud/sensors/test_pubsub.py
index 795860b..6a502aa 100644
--- a/tests/providers/google/cloud/sensors/test_pubsub.py
+++ b/tests/providers/google/cloud/sensors/test_pubsub.py
@@ -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"},
diff --git a/tests/providers/snowflake/transfers/test_s3_to_snowflake.py b/tests/providers/snowflake/transfers/test_s3_to_snowflake.py
index 02e6e5a..f965acf 100644
--- a/tests/providers/snowflake/transfers/test_s3_to_snowflake.py
+++ b/tests/providers/snowflake/transfers/test_s3_to_snowflake.py
@@ -46,19 +46,15 @@ class TestS3ToSnowflakeTransfer(unittest.TestCase):
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)
@@ -86,13 +82,11 @@ class TestS3ToSnowflakeTransfer(unittest.TestCase):
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}