-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DTZ
rules: Clarify error messages and docs
#10621
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
DTZ001 | 1396 | 698 | 698 | 0 | 0 |
DTZ005 | 218 | 109 | 109 | 0 | 0 |
DTZ007 | 40 | 20 | 20 | 0 | 0 |
DTZ006 | 34 | 17 | 17 | 0 | 0 |
DTZ002 | 30 | 15 | 15 | 0 | 0 |
DTZ011 | 16 | 8 | 8 | 0 | 0 |
DTZ012 | 2 | 1 | 1 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+868 -868 violations, +0 -0 fixes in 3 projects; 41 projects unchanged)
apache/airflow (+797 -797 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
- airflow/dag_processing/manager.py:415:62: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed + airflow/dag_processing/manager.py:415:62: DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument - airflow/dag_processing/manager.py:419:68: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed + airflow/dag_processing/manager.py:419:68: DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument - airflow/example_dags/example_dynamic_task_mapping.py:27:60: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed + airflow/example_dags/example_dynamic_task_mapping.py:27:60: DTZ001 `datetime.datetime()` called without a `tzinfo` argument - airflow/example_dags/example_dynamic_task_mapping_with_no_taskflow_operators.py:56:16: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed + airflow/example_dags/example_dynamic_task_mapping_with_no_taskflow_operators.py:56:16: DTZ001 `datetime.datetime()` called without a `tzinfo` argument - airflow/example_dags/example_latest_only.py:31:16: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed + airflow/example_dags/example_latest_only.py:31:16: DTZ001 `datetime.datetime()` called without a `tzinfo` argument - airflow/example_dags/example_local_kubernetes_executor.py:48:20: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed ... 1280 additional changes omitted for rule DTZ001 - airflow/example_dags/example_params_ui_tutorial.py:145:16: DTZ011 The use of `datetime.date.today()` is not allowed, use `datetime.datetime.now(tz=).date()` instead + airflow/example_dags/example_params_ui_tutorial.py:145:16: DTZ011 `datetime.date.today()` used - airflow/example_dags/example_params_ui_tutorial.py:152:16: DTZ011 The use of `datetime.date.today()` is not allowed, use `datetime.datetime.now(tz=).date()` instead + airflow/example_dags/example_params_ui_tutorial.py:152:16: DTZ011 `datetime.date.today()` used + airflow/macros/__init__.py:59:10: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z - airflow/macros/__init__.py:59:10: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` + airflow/macros/__init__.py:76:12: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z - airflow/macros/__init__.py:76:12: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` - airflow/models/dagbag.py:298:41: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed + airflow/models/dagbag.py:298:41: DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument - airflow/providers/amazon/aws/hooks/s3.py:699:34: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed + airflow/providers/amazon/aws/hooks/s3.py:699:34: DTZ005 `datetime.datetime.now()` called without a `tz` argument - airflow/providers/amazon/aws/hooks/s3.py:714:38: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed + airflow/providers/amazon/aws/hooks/s3.py:714:38: DTZ005 `datetime.datetime.now()` called without a `tz` argument - airflow/providers/amazon/aws/hooks/s3.py:738:34: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed + airflow/providers/amazon/aws/hooks/s3.py:738:34: DTZ005 `datetime.datetime.now()` called without a `tz` argument - airflow/providers/amazon/aws/sensors/s3.py:291:39: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed ... 194 additional changes omitted for rule DTZ005 + airflow/providers/apache/hive/macros/hive.py:113:18: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z - airflow/providers/apache/hive/macros/hive.py:113:18: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` + airflow/providers/apache/hive/macros/hive.py:114:21: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z ... 34 additional changes omitted for rule DTZ007 - airflow/providers/apache/kylin/operators/kylin_cube.py:147:22: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed ... 22 additional changes omitted for rule DTZ006 - airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py:108:61: DTZ011 The use of `datetime.date.today()` is not allowed, use `datetime.datetime.now(tz=).date()` instead + airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py:108:61: DTZ011 `datetime.date.today()` used - airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py:108:94: DTZ011 The use of `datetime.date.today()` is not allowed, use `datetime.datetime.now(tz=).date()` instead ... 6 additional changes omitted for rule DTZ011 - airflow/sensors/time_sensor.py:70:39: DTZ002 The use of `datetime.datetime.today()` is not allowed, use `datetime.datetime.now(tz=)` instead + airflow/sensors/time_sensor.py:70:39: DTZ002 `datetime.datetime.today()` used - airflow/utils/log/file_processor_handler.py:52:26: DTZ002 The use of `datetime.datetime.today()` is not allowed, use `datetime.datetime.now(tz=)` instead + airflow/utils/log/file_processor_handler.py:52:26: DTZ002 `datetime.datetime.today()` used - airflow/utils/log/file_processor_handler.py:68:29: DTZ002 The use of `datetime.datetime.today()` is not allowed, use `datetime.datetime.now(tz=)` instead + airflow/utils/log/file_processor_handler.py:68:29: DTZ002 `datetime.datetime.today()` used - airflow/utils/log/file_processor_handler.py:70:30: DTZ002 The use of `datetime.datetime.today()` is not allowed, use `datetime.datetime.now(tz=)` instead ... 20 additional changes omitted for rule DTZ002 - tests/providers/sftp/triggers/test_sftp.py:152:38: DTZ012 The use of `datetime.date.fromtimestamp()` is not allowed, use `datetime.datetime.fromtimestamp(ts, tz=).date()` instead + tests/providers/sftp/triggers/test_sftp.py:152:38: DTZ012 `datetime.date.fromtimestamp()` used ... 1550 additional changes omitted for project
bokeh/bokeh (+70 -70 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
- docs/bokeh/source/conf.py:21:8: DTZ011 The use of `datetime.date.today()` is not allowed, use `datetime.datetime.now(tz=).date()` instead + docs/bokeh/source/conf.py:21:8: DTZ011 `datetime.date.today()` used - docs/bokeh/source/docs/first_steps/examples/first_steps_4_datetime_axis.py:8:11: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed + docs/bokeh/source/docs/first_steps/examples/first_steps_4_datetime_axis.py:8:11: DTZ005 `datetime.datetime.now()` called without a `tz` argument - examples/basic/annotations/polygon_annotation.py:17:14: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed + examples/basic/annotations/polygon_annotation.py:17:14: DTZ001 `datetime.datetime()` called without a `tzinfo` argument - examples/basic/annotations/polygon_annotation.py:20:12: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed + examples/basic/annotations/polygon_annotation.py:20:12: DTZ001 `datetime.datetime()` called without a `tzinfo` argument - examples/basic/annotations/span.py:18:27: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed + examples/basic/annotations/span.py:18:27: DTZ001 `datetime.datetime()` called without a `tzinfo` argument ... 105 additional changes omitted for rule DTZ001 ... 130 additional changes omitted for project
rotki/rotki (+1 -1 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
- packaging/docker/entrypoint.py:26:20: DTZ002 The use of `datetime.datetime.today()` is not allowed, use `datetime.datetime.now(tz=)` instead + packaging/docker/entrypoint.py:26:20: DTZ002 `datetime.datetime.today()` used
Changes by rule (7 rules affected)
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
DTZ001 | 1396 | 698 | 698 | 0 | 0 |
DTZ005 | 218 | 109 | 109 | 0 | 0 |
DTZ007 | 40 | 20 | 20 | 0 | 0 |
DTZ006 | 34 | 17 | 17 | 0 | 0 |
DTZ002 | 30 | 15 | 15 | 0 | 0 |
DTZ011 | 16 | 8 | 8 | 0 | 0 |
DTZ012 | 2 | 1 | 1 | 0 | 0 |
AlexWaygood
added
documentation
Improvements or additions to documentation
rule
Implementing or modifying a lint rule
labels
Mar 26, 2024
cclauss
reviewed
Mar 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
VascoSch92
reviewed
Mar 26, 2024
crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs
Outdated
Show resolved
Hide resolved
MichaReiser
approved these changes
Mar 27, 2024
...lake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap
Outdated
Show resolved
Hide resolved
...lake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap
Outdated
Show resolved
Hide resolved
AlexWaygood
force-pushed
the
dtz-clarify
branch
from
March 27, 2024 16:43
23e8a23
to
5f5f523
Compare
AlexWaygood
force-pushed
the
dtz-clarify
branch
from
March 27, 2024 19:33
5f5f523
to
300ac2f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #10251. Closes #10590.
Summary
This PR builds upon #10590, by @cclauss. The problem with DTZ005 pointed out in #10251 is really a common problem to most of the DTZ rules, so it makes sense to tackle them all at the same time.
Changes made:
tz=None
is just as bad as not passing atz=
argument, from the perspective of these rules.tz=None
rather than failing to pass atz=
argument at all.Test Plan
cargo test
Co-authored-by: Christian Clauss cclauss@me.com