-
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
Add singleton escape hatch to B008 documentation #8501
Conversation
} 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") |
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.
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?
|
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 |
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.
I'd like a shorter error message with a fix showing using the singleton
c6fe39e
to
f0e7c16
Compare
Summary:
Closes: #8378.