You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2023/08/29 07:50:35 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #33859: Replace format() by f-string in tests

uranusjr commented on code in PR #33859:
URL: https://github.com/apache/airflow/pull/33859#discussion_r1308365470


##########
tests/providers/postgres/hooks/test_postgres.py:
##########
@@ -429,8 +429,8 @@ def test_insert_rows_replace(self):
         assert commit_count == self.conn.commit.call_count
 
         sql = (
-            "INSERT INTO {0} ({1}, {2}) VALUES (%s,%s) "
-            "ON CONFLICT ({1}) DO UPDATE SET {2} = excluded.{2}".format(table, fields[0], fields[1])
+            f"INSERT INTO {table} ({fields[0]}, {fields[1]}) VALUES (%s,%s) "
+            f"ON CONFLICT ({fields[0]}) DO UPDATE SET {fields[1]} = excluded.{fields[1]}"

Review Comment:
   I feel this is where `format()` can be superior to f-string. There are other cases in this PR I’m not sure f-string is really better.



##########
tests/providers/postgres/hooks/test_postgres.py:
##########
@@ -429,8 +429,8 @@ def test_insert_rows_replace(self):
         assert commit_count == self.conn.commit.call_count
 
         sql = (
-            "INSERT INTO {0} ({1}, {2}) VALUES (%s,%s) "
-            "ON CONFLICT ({1}) DO UPDATE SET {2} = excluded.{2}".format(table, fields[0], fields[1])
+            f"INSERT INTO {table} ({fields[0]}, {fields[1]}) VALUES (%s,%s) "
+            f"ON CONFLICT ({fields[0]}) DO UPDATE SET {fields[1]} = excluded.{fields[1]}"

Review Comment:
   I feel this is where `format()` can be superior to f-string. There are other cases in this PR I’m not sure f-string is really better.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org