ruff
ruff copied to clipboard
Add rule WPS111 from wemake-python-styleguide
Summary
Implements WPS111 from wemake-python-styleguide, as part of #3845.
I started by merging latest upstream changes into an existing PR to revive this implementation. However, after looking at it more closely, I realized that the existing implementation only covers the most basic case of WPS111. After studying the original code a bit more I updated my implementation to match the original more closely and emit the same behavior. The result is a quite substantial difference compared to the existing PR for this rule, so I decided to make it a separate one, supposed to supersede the previous.
Test Plan
I added a fixture for snapshot testing and copied unit tests from the original logic.
PR Check Results
Ecosystem
✅ ecosystem check detected no linter changes.
✅ ecosystem check detected no format changes.
CodSpeed Performance Report
Merging #5632 will not alter performance
Comparing bo5o:wps111-too_short_name-new (2d03f74) with main (895d9df)
Summary
✅ 30 untouched benchmarks
ruff-ecosystem results
Linter (stable)
✅ ecosystem check detected no linter changes.
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+9643 -0 violations, +0 -0 fixes in 3 projects; 41 projects unchanged)
apache/airflow (+3827 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ airflow/api/auth/backend/default.py:32:1: WPS111 Found too short name: `T` + airflow/api/auth/backend/deny_all.py:34:1: WPS111 Found too short name: `T` + airflow/api/auth/backend/kerberos_auth.py:138:1: WPS111 Found too short name: `T` + airflow/api/auth/backend/session.py:35:1: WPS111 Found too short name: `T` + airflow/api/client/json_client.py:110:63: WPS111 Found too short name: `p` + airflow/api/client/local_client.py:70:74: WPS111 Found too short name: `p` + airflow/api/common/mark_tasks.py:317:46: WPS111 Found too short name: `d` + airflow/api/common/mark_tasks.py:346:40: WPS111 Found too short name: `d` + airflow/api_connexion/endpoints/config_endpoint.py:60:50: WPS111 Found too short name: `s` + airflow/api_connexion/endpoints/connection_endpoint.py:168:25: WPS111 Found too short name: `e` + airflow/api_connexion/endpoints/dag_endpoint.py:138:26: WPS111 Found too short name: `e` + airflow/api_connexion/endpoints/dag_endpoint.py:65:26: WPS111 Found too short name: `e` + airflow/api_connexion/endpoints/dag_endpoint.py:87:26: WPS111 Found too short name: `e` + airflow/api_connexion/endpoints/dag_run_endpoint.py:108:26: WPS111 Found too short name: `e` + airflow/api_connexion/endpoints/dag_run_endpoint.py:258:26: WPS111 Found too short name: `e` + airflow/api_connexion/endpoints/pool_endpoint.py:114:38: WPS111 Found too short name: `i` + airflow/api_connexion/endpoints/provider_endpoint.py:52:42: WPS111 Found too short name: `d` + airflow/api_connexion/endpoints/task_instance_endpoint.py:264:71: WPS111 Found too short name: `s` + airflow/api_connexion/endpoints/task_instance_endpoint.py:269:32: WPS111 Found too short name: `v` ... 3808 additional changes omitted for project
bokeh/bokeh (+4254 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ docs/bokeh/source/docs/first_steps/examples/first_steps_1_multiple_lines.py:10:1: WPS111 Found too short name: `p` + docs/bokeh/source/docs/first_steps/examples/first_steps_1_multiple_lines.py:4:1: WPS111 Found too short name: `x` + docs/bokeh/source/docs/first_steps/examples/first_steps_1_simple_line.py:4:1: WPS111 Found too short name: `x` + docs/bokeh/source/docs/first_steps/examples/first_steps_1_simple_line.py:5:1: WPS111 Found too short name: `y` + docs/bokeh/source/docs/first_steps/examples/first_steps_1_simple_line.py:8:1: WPS111 Found too short name: `p` + docs/bokeh/source/docs/first_steps/examples/first_steps_2_add_bars.py:10:1: WPS111 Found too short name: `p` + docs/bokeh/source/docs/first_steps/examples/first_steps_2_add_bars.py:4:1: WPS111 Found too short name: `x` + docs/bokeh/source/docs/first_steps/examples/first_steps_2_add_circles.py:10:1: WPS111 Found too short name: `p` + docs/bokeh/source/docs/first_steps/examples/first_steps_2_add_circles.py:4:1: WPS111 Found too short name: `x` + docs/bokeh/source/docs/first_steps/examples/first_steps_2_style_circle.py:4:1: WPS111 Found too short name: `x` + docs/bokeh/source/docs/first_steps/examples/first_steps_2_style_circle.py:5:1: WPS111 Found too short name: `y` + docs/bokeh/source/docs/first_steps/examples/first_steps_2_style_circle.py:8:1: WPS111 Found too short name: `p` + docs/bokeh/source/docs/first_steps/examples/first_steps_2_style_existing_circle.py:4:1: WPS111 Found too short name: `x` + docs/bokeh/source/docs/first_steps/examples/first_steps_2_style_existing_circle.py:5:1: WPS111 Found too short name: `y` + docs/bokeh/source/docs/first_steps/examples/first_steps_2_style_existing_circle.py:8:1: WPS111 Found too short name: `p` + docs/bokeh/source/docs/first_steps/examples/first_steps_3_box_annotation.py:11:1: WPS111 Found too short name: `p` + docs/bokeh/source/docs/first_steps/examples/first_steps_3_box_annotation.py:7:1: WPS111 Found too short name: `x` + docs/bokeh/source/docs/first_steps/examples/first_steps_3_box_annotation.py:8:1: WPS111 Found too short name: `y` + docs/bokeh/source/docs/first_steps/examples/first_steps_3_legend.py:4:1: WPS111 Found too short name: `x` + docs/bokeh/source/docs/first_steps/examples/first_steps_3_legend.py:9:1: WPS111 Found too short name: `p` + docs/bokeh/source/docs/first_steps/examples/first_steps_3_title.py:4:1: WPS111 Found too short name: `x` + docs/bokeh/source/docs/first_steps/examples/first_steps_3_title.py:5:1: WPS111 Found too short name: `y` ... 4232 additional changes omitted for project
zulip/zulip (+1562 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ analytics/lib/fixtures.py:48:13: WPS111 Found too short name: `i` + analytics/lib/fixtures.py:55:53: WPS111 Found too short name: `i` + analytics/lib/fixtures.py:63:81: WPS111 Found too short name: `i` + analytics/lib/fixtures.py:66:9: WPS111 Found too short name: `i` + analytics/lib/fixtures.py:73:13: WPS111 Found too short name: `v` + analytics/lib/fixtures.py:76:13: WPS111 Found too short name: `i` + analytics/lib/fixtures.py:78:27: WPS111 Found too short name: `v` + analytics/management/commands/check_analytics_state.py:37:43: WPS111 Found too short name: `f` + analytics/migrations/0016_unique_constraint_when_subgroup_null.py:31:34: WPS111 Found too short name: `Q` + analytics/migrations/0016_unique_constraint_when_subgroup_null.py:39:34: WPS111 Found too short name: `Q` ... 1552 additional changes omitted for project
Changes by rule (1 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| WPS111 | 9643 | 9643 | 0 | 0 | 0 |
Formatter (stable)
✅ ecosystem check detected no format changes.
Formatter (preview)
✅ ecosystem check detected no format changes.
Thank you, @bo5o, for working on this rule and keeping the PR up to date.
We think this is a valuable rule for many but don't feel comfortable merging it today because it is very opinionated, and everyone using --select ALL would opt into the new rule. That's why we only want to add this rule once #1774 is complete: It gives users a better way to opt into the rules they want.
I'm closing this PR for now because I don't want you to spend more time updating the PR, but I hope we can resurrect this PR once #1774 is completed. I'm sorry for the late reply. We should have made this decision sooner.