You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "eumiro (via GitHub)" <gi...@apache.org> on 2023/08/16 17:33:28 UTC
[GitHub] [airflow] eumiro opened a new pull request, #33453: Simplify 'X for X in Y' to 'Y' where applicable
eumiro opened a new pull request, #33453:
URL: https://github.com/apache/airflow/pull/33453
Simplify loops without condition `X for X in Y` to bare `Y`, or convert it to `list()` or `set()` or `iter()` if needed.
--
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
[GitHub] [airflow] uranusjr commented on a diff in pull request #33453: Simplify 'X for X in Y' to 'Y' where applicable
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #33453:
URL: https://github.com/apache/airflow/pull/33453#discussion_r1296740570
##########
tests/providers/google/cloud/transfers/test_sql_to_gcs.py:
##########
@@ -557,7 +557,7 @@ def test__write_local_data_files_csv_does_not_write_on_empty_rows(self):
with pytest.raises(StopIteration):
next(files)["file_handle"]
- assert len([f for f in files]) == 0
+ assert len(files) == 0
Review Comment:
I think `files` is an iterator here
--
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
[GitHub] [airflow] eumiro commented on a diff in pull request #33453: Simplify 'X for X in Y' to 'Y' where applicable
Posted by "eumiro (via GitHub)" <gi...@apache.org>.
eumiro commented on code in PR #33453:
URL: https://github.com/apache/airflow/pull/33453#discussion_r1298693274
##########
tests/providers/google/cloud/transfers/test_sql_to_gcs.py:
##########
@@ -557,7 +557,7 @@ def test__write_local_data_files_csv_does_not_write_on_empty_rows(self):
with pytest.raises(StopIteration):
next(files)["file_handle"]
- assert len([f for f in files]) == 0
+ assert not list(files)
Review Comment:
This is really elegant. anyway, since the previous block already expects a `StopIteration`, we do not have to repeat it here. I'll remove it altogether.
##########
tests/providers/google/cloud/transfers/test_sql_to_gcs.py:
##########
@@ -557,7 +557,7 @@ def test__write_local_data_files_csv_does_not_write_on_empty_rows(self):
with pytest.raises(StopIteration):
next(files)["file_handle"]
- assert len([f for f in files]) == 0
+ assert not list(files)
Review Comment:
This is really elegant. Anyway, since the previous block already expects a `StopIteration`, we do not have to repeat it here. I'll remove it altogether.
--
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
[GitHub] [airflow] eumiro commented on a diff in pull request #33453: Simplify 'X for X in Y' to 'Y' where applicable
Posted by "eumiro (via GitHub)" <gi...@apache.org>.
eumiro commented on code in PR #33453:
URL: https://github.com/apache/airflow/pull/33453#discussion_r1298693274
##########
tests/providers/google/cloud/transfers/test_sql_to_gcs.py:
##########
@@ -557,7 +557,7 @@ def test__write_local_data_files_csv_does_not_write_on_empty_rows(self):
with pytest.raises(StopIteration):
next(files)["file_handle"]
- assert len([f for f in files]) == 0
+ assert not list(files)
Review Comment:
This is really elegant!
--
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
[GitHub] [airflow] uranusjr commented on a diff in pull request #33453: Simplify 'X for X in Y' to 'Y' where applicable
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #33453:
URL: https://github.com/apache/airflow/pull/33453#discussion_r1296742355
##########
tests/sensors/test_external_task_sensor.py:
##########
@@ -1478,7 +1478,7 @@ def dummy_task(x: int):
mode="reschedule",
)
- body = dummy_task.expand(x=[i for i in range(5)])
+ body = dummy_task.expand(x=list(range(5)))
Review Comment:
Actually I don’t think even the `list` is needed, `expand` should be able to accept `range` since it implements the sequence protocol.
##########
tests/sensors/test_external_task_sensor.py:
##########
@@ -1478,7 +1478,7 @@ def dummy_task(x: int):
mode="reschedule",
)
- body = dummy_task.expand(x=[i for i in range(5)])
+ body = dummy_task.expand(x=list(range(5)))
Review Comment:
Actually I don’t think even the `list` is needed, `expand` should be able to accept `range` since it implements the sequence protocol.
--
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
[GitHub] [airflow] uranusjr commented on a diff in pull request #33453: Simplify 'X for X in Y' to 'Y' where applicable
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #33453:
URL: https://github.com/apache/airflow/pull/33453#discussion_r1298053164
##########
tests/providers/google/cloud/transfers/test_sql_to_gcs.py:
##########
@@ -557,7 +557,7 @@ def test__write_local_data_files_csv_does_not_write_on_empty_rows(self):
with pytest.raises(StopIteration):
next(files)["file_handle"]
- assert len([f for f in files]) == 0
+ assert not list(files)
Review Comment:
```suggestion
with pytest.raises(StopIteration):
next(files)
```
Alternative approach. Shouldn’t be too much difference in practice (especially in a test).
##########
tests/providers/google/cloud/transfers/test_sql_to_gcs.py:
##########
@@ -557,7 +557,7 @@ def test__write_local_data_files_csv_does_not_write_on_empty_rows(self):
with pytest.raises(StopIteration):
next(files)["file_handle"]
- assert len([f for f in files]) == 0
+ assert not list(files)
Review Comment:
```suggestion
with pytest.raises(StopIteration):
next(files)
```
Alternative approach. Shouldn’t be too much difference in practice (especially in a test).
--
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
[GitHub] [airflow] hussein-awala commented on a diff in pull request #33453: Simplify 'X for X in Y' to 'Y' where applicable
Posted by "hussein-awala (via GitHub)" <gi...@apache.org>.
hussein-awala commented on code in PR #33453:
URL: https://github.com/apache/airflow/pull/33453#discussion_r1296240922
##########
tests/conftest.py:
##########
@@ -134,7 +134,7 @@ def pytest_print(text):
# It is very unlikely that the user wants to display only numbers, but probably
# the user just wants to count the queries.
exit_stack.enter_context(count_queries(print_fn=pytest_print))
- elif any(c for c in ["time", "trace", "sql", "parameters"]):
+ elif any(c in columns for c in ["time", "trace", "sql", "parameters"]):
Review Comment:
Nice catch
--
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
[GitHub] [airflow] potiuk merged pull request #33453: Simplify 'X for X in Y' to 'Y' where applicable
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #33453:
URL: https://github.com/apache/airflow/pull/33453
--
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