Add singleton escape hatch to B008 documentation#8501
Merged
charliermarsh merged 1 commit intomainfrom Nov 7, 2023
Merged
Conversation
charliermarsh
commented
Nov 6, 2023
| format!("Do not perform function call `{name}` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable") | ||
| } else { | ||
| format!("Do not perform function call in argument defaults") | ||
| format!("Do not perform function call in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable") |
Member
Author
There was a problem hiding this comment.
I'm not a huge fan of bugbear's error messages which tend to be very long (https://github.com/PyCQA/flake8-bugbear/blob/907e0dd29a99818591a604d4557c70ea33204712/bugbear.py#L1660-L1667). I prefer to put that level of detail in our documentation, or make it evident via the proposed fix. But I do think this one can be a bit clearer. Wdyt @zanieb?
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| B008 | 186 | 93 | 93 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+93 -93 violations, +0 -0 fixes in 41 projects)
apache/airflow (+16 -16 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --select ALL --preview
- airflow/metrics/datadog_logger.py:49:44: B008 Do not perform function call `AllowListValidator` in argument defaults + airflow/metrics/datadog_logger.py:49:44: B008 Do not perform function call `AllowListValidator` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - airflow/metrics/datadog_logger.py:51:48: B008 Do not perform function call `AllowListValidator` in argument defaults + airflow/metrics/datadog_logger.py:51:48: B008 Do not perform function call `AllowListValidator` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - airflow/metrics/otel_logger.py:169:30: B008 Do not perform function call `AllowListValidator` in argument defaults + airflow/metrics/otel_logger.py:169:30: B008 Do not perform function call `AllowListValidator` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - airflow/metrics/statsd_logger.py:72:44: B008 Do not perform function call `AllowListValidator` in argument defaults + airflow/metrics/statsd_logger.py:72:44: B008 Do not perform function call `AllowListValidator` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - airflow/metrics/statsd_logger.py:74:48: B008 Do not perform function call `AllowListValidator` in argument defaults + airflow/metrics/statsd_logger.py:74:48: B008 Do not perform function call `AllowListValidator` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable ... 22 additional changes omitted for project
bokeh/bokeh (+1 -1 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --select ALL --preview
- src/bokeh/server/tornado.py:274:48: B008 Do not perform function call `NullAuth` in argument defaults + src/bokeh/server/tornado.py:274:48: B008 Do not perform function call `NullAuth` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
latchbio/latch (+1 -1 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --preview
- latch/verified/pathway.py:17:33: B008 Do not perform function call `LatchDir` in argument defaults + latch/verified/pathway.py:17:33: B008 Do not perform function call `LatchDir` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
zulip/zulip (+75 -75 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --select ALL --preview
- analytics/views/stats.py:254:33: B008 Do not perform function call `REQ` in argument defaults + analytics/views/stats.py:254:33: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - analytics/views/stats.py:255:31: B008 Do not perform function call `REQ` in argument defaults + analytics/views/stats.py:255:31: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - analytics/views/support.py:165:35: B008 Do not perform function call `REQ` in argument defaults + analytics/views/support.py:165:35: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - confirmation/models.py:118:67: B008 Do not perform function call `UnspecifiedValue` in argument defaults + confirmation/models.py:118:67: B008 Do not perform function call `UnspecifiedValue` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/actions/invites.py:54:73: B008 Do not perform function call `UnspecifiedValue` in argument defaults + zerver/actions/invites.py:54:73: B008 Do not perform function call `UnspecifiedValue` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/models.py:2526:73: B008 Do not perform function call `UnspecifiedValue` in argument defaults + zerver/models.py:2526:73: B008 Do not perform function call `UnspecifiedValue` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/tests/test_has_request_variables.py:138:61: B008 Do not perform function call `REQ` in argument defaults + zerver/tests/test_has_request_variables.py:138:61: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/tests/test_typed_endpoint.py:87:39: B008 Do not perform function call `Foo` in argument defaults + zerver/tests/test_typed_endpoint.py:87:39: B008 Do not perform function call `Foo` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/tornado/views.py:114:37: B008 Do not perform function call `REQ` in argument defaults + zerver/tornado/views.py:114:37: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/views/custom_profile_fields.py:154:36: B008 Do not perform function call `REQ` in argument defaults + zerver/views/custom_profile_fields.py:154:36: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/views/custom_profile_fields.py:209:36: B008 Do not perform function call `REQ` in argument defaults + zerver/views/custom_profile_fields.py:209:36: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/views/custom_profile_fields.py:259:24: B008 Do not perform function call `REQ` in argument defaults + zerver/views/custom_profile_fields.py:259:24: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/views/custom_profile_fields.py:259:43: B008 Do not perform function call `check_list` in argument defaults + zerver/views/custom_profile_fields.py:259:43: B008 Do not perform function call `check_list` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/views/custom_profile_fields.py:270:23: B008 Do not perform function call `REQ` in argument defaults + zerver/views/custom_profile_fields.py:270:23: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/views/custom_profile_fields.py:270:42: B008 Do not perform function call `check_list` in argument defaults + zerver/views/custom_profile_fields.py:270:42: B008 Do not perform function call `check_list` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/views/custom_profile_fields.py:293:48: B008 Do not perform function call `REQ` in argument defaults + zerver/views/custom_profile_fields.py:293:48: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/views/custom_profile_fields.py:294:24: B008 Do not perform function call `check_list` in argument defaults + zerver/views/custom_profile_fields.py:294:24: B008 Do not perform function call `check_list` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/views/events_register.py:52:54: B008 Do not perform function call `REQ` in argument defaults + zerver/views/events_register.py:52:54: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/views/events_register.py:53:24: B008 Do not perform function call `check_dict` in argument defaults + zerver/views/events_register.py:53:24: B008 Do not perform function call `check_dict` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable - zerver/views/events_register.py:78:23: B008 Do not perform function call `REQ` in argument defaults + zerver/views/events_register.py:78:23: B008 Do not perform function call `REQ` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable ... 110 additional changes omitted for project
Changes by rule (1 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| B008 | 186 | 93 | 93 | 0 | 0 |
konstin
approved these changes
Nov 6, 2023
Member
konstin
left a comment
There was a problem hiding this comment.
I'd like a shorter error message with a fix showing using the singleton
c6fe39e to
f0e7c16
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary:
Closes: #8378.