Skip to content
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

[ruff] Implemented wrong-class-body-content (RUF050) #14607

Closed

Conversation

Lokejoke
Copy link
Contributor

Summary

This PR implement wps rule wrong-class-body-content rule. After discussion here

Test Plan

cargo test

Copy link
Contributor

github-actions bot commented Nov 26, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+245 -0 violations, +0 -0 fixes in 14 projects; 41 projects unchanged)

DisnakeDev/disnake (+38 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ disnake/abc.py:268:5: RUF050 Wrong statement inside class definition
+ disnake/audit_logs.py:304:5: RUF050 Wrong statement inside class definition
+ disnake/components.py:414:5: RUF050 Wrong statement inside class definition
+ disnake/components.py:454:5: RUF050 Wrong statement inside class definition
+ disnake/components.py:494:5: RUF050 Wrong statement inside class definition
+ disnake/embeds.py:227:5: RUF050 Wrong statement inside class definition
+ disnake/enums.py:113:5: RUF050 Wrong statement inside class definition
+ disnake/enums.py:81:5: RUF050 Wrong statement inside class definition
+ disnake/enums.py:872:5: RUF050 Wrong statement inside class definition
+ disnake/ext/commands/bot.py:220:5: RUF050 Wrong statement inside class definition
... 28 additional changes omitted for project

apache/airflow (+12 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ airflow/cli/commands/info_command.py:66:5: RUF050 Wrong statement inside class definition
+ airflow/models/baseoperator.py:642:5: RUF050 Wrong statement inside class definition
+ airflow/models/dagrun.py:173:5: RUF050 Wrong statement inside class definition
+ airflow/serialization/serialized_objects.py:1612:5: RUF050 Wrong statement inside class definition
+ airflow/www/views.py:706:5: RUF050 Wrong statement inside class definition
+ airflow/www/views.py:716:5: RUF050 Wrong statement inside class definition
+ providers/src/airflow/providers/edge/plugins/edge_executor_plugin.py:134:5: RUF050 Wrong statement inside class definition
+ providers/src/airflow/providers/hashicorp/secrets/vault.py:212:5: RUF050 Wrong statement inside class definition
+ providers/src/airflow/providers/openlineage/plugins/listener.py:274:5: RUF050 Wrong statement inside class definition
+ providers/src/airflow/providers/openlineage/plugins/openlineage.py:40:5: RUF050 Wrong statement inside class definition
... 2 additional changes omitted for project

apache/superset (+2 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ superset/db_engine_specs/ascend.py:27:5: RUF050 Wrong statement inside class definition
+ superset/db_engine_specs/sqlite.py:99:5: RUF050 Wrong statement inside class definition

bokeh/bokeh (+4 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ src/bokeh/sphinxext/bokehjs_content.py:126:5: RUF050 Wrong statement inside class definition
+ src/bokeh/sphinxext/bokehjs_content.py:127:5: RUF050 Wrong statement inside class definition
+ src/bokeh/sphinxext/bokehjs_content.py:128:5: RUF050 Wrong statement inside class definition
+ src/bokeh/sphinxext/bokehjs_content.py:129:5: RUF050 Wrong statement inside class definition

ibis-project/ibis (+2 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ ibis/backends/sql/dialects.py:246:9: RUF050 Wrong statement inside class definition
+ ibis/backends/sql/dialects.py:29:9: RUF050 Wrong statement inside class definition

pandas-dev/pandas (+105 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ asv_bench/benchmarks/dtypes.py:55:5: RUF050 Wrong statement inside class definition
+ pandas/io/excel/_base.py:1544:5: RUF050 Wrong statement inside class definition
+ pandas/io/excel/_base.py:1545:5: RUF050 Wrong statement inside class definition
+ pandas/io/excel/_base.py:1546:5: RUF050 Wrong statement inside class definition
+ pandas/io/excel/_base.py:1547:5: RUF050 Wrong statement inside class definition
+ pandas/io/excel/_base.py:1548:5: RUF050 Wrong statement inside class definition
+ pandas/io/formats/css.py:147:5: RUF050 Wrong statement inside class definition
+ pandas/io/formats/css.py:164:5: RUF050 Wrong statement inside class definition
+ pandas/io/formats/css.py:167:5: RUF050 Wrong statement inside class definition
+ pandas/io/formats/format.py:424:5: RUF050 Wrong statement inside class definition
+ pandas/io/formats/style.py:3706:13: RUF050 Wrong statement inside class definition
+ pandas/io/formats/style.py:3708:13: RUF050 Wrong statement inside class definition
+ pandas/io/stata.py:825:5: RUF050 Wrong statement inside class definition
+ pandas/io/stata.py:833:5: RUF050 Wrong statement inside class definition
+ pandas/io/stata.py:843:5: RUF050 Wrong statement inside class definition
+ pandas/tests/api/test_api.py:194:5: RUF050 Wrong statement inside class definition
+ pandas/tests/dtypes/test_inference.py:358:9: RUF050 Wrong statement inside class definition
+ pandas/tests/dtypes/test_inference.py:363:9: RUF050 Wrong statement inside class definition
+ pandas/tests/dtypes/test_inference.py:368:9: RUF050 Wrong statement inside class definition
+ pandas/tests/indexing/test_coercion.py:756:5: RUF050 Wrong statement inside class definition
+ pandas/tests/series/test_arithmetic.py:109:5: RUF050 Wrong statement inside class definition
... 84 additional changes omitted for project

python/typeshed (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select E,F,FA,I,PYI,RUF,UP,W

+ stubs/mysqlclient/MySQLdb/cursors.pyi:13:5: RUF050 Wrong statement inside class definition

rotki/rotki (+3 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ rotkehlchen/api/rest.py:1671:5: RUF050 Wrong statement inside class definition
+ rotkehlchen/api/v1/resources.py:1548:5: RUF050 Wrong statement inside class definition
+ rotkehlchen/chain/evm/decoding/decoder.py:1167:5: RUF050 Wrong statement inside class definition

zulip/zulip (+5 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ zerver/management/commands/makemessages.py:82:5: RUF050 Wrong statement inside class definition
+ zerver/migrations/0001_initial.py:24:5: RUF050 Wrong statement inside class definition
+ zerver/migrations/0001_initial.py:38:5: RUF050 Wrong statement inside class definition
+ zerver/models/realms.py:564:5: RUF050 Wrong statement inside class definition
+ zerver/models/realms.py:570:5: RUF050 Wrong statement inside class definition

indico/indico (+12 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ indico/core/marshmallow.py:34:5: RUF050 Wrong statement inside class definition
+ indico/modules/auth/controllers.py:475:13: RUF050 Wrong statement inside class definition
+ indico/modules/auth/controllers.py:482:13: RUF050 Wrong statement inside class definition
+ indico/modules/auth/controllers.py:485:13: RUF050 Wrong statement inside class definition
+ indico/modules/events/abstracts/models/abstracts.py:50:5: RUF050 Wrong statement inside class definition
+ indico/modules/events/abstracts/models/abstracts.py:52:5: RUF050 Wrong statement inside class definition
+ indico/modules/events/registration/models/registrations.py:915:5: RUF050 Wrong statement inside class definition
+ indico/modules/rb/models/reservation_occurrences.py:77:5: RUF050 Wrong statement inside class definition
+ indico/modules/rb/models/reservation_occurrences.py:78:5: RUF050 Wrong statement inside class definition
+ indico/modules/users/export_schemas.py:288:5: RUF050 Wrong statement inside class definition
... 2 additional changes omitted for project

python-trio/trio (+27 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ src/trio/_core/_run.py:1048:5: RUF050 Wrong statement inside class definition
+ src/trio/_file_io.py:237:5: RUF050 Wrong statement inside class definition
+ src/trio/_file_io.py:300:5: RUF050 Wrong statement inside class definition
+ src/trio/_path.py:215:5: RUF050 Wrong statement inside class definition
+ src/trio/_path.py:221:5: RUF050 Wrong statement inside class definition
+ src/trio/_path.py:224:5: RUF050 Wrong statement inside class definition
+ src/trio/_path.py:232:5: RUF050 Wrong statement inside class definition
+ src/trio/_path.py:243:5: RUF050 Wrong statement inside class definition
+ src/trio/_path.py:245:5: RUF050 Wrong statement inside class definition
+ src/trio/_socket.py:1119:5: RUF050 Wrong statement inside class definition
... 17 additional changes omitted for project

pytest-dev/pytest (+12 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ src/_pytest/_py/path.py:204:5: RUF050 Wrong statement inside class definition
+ src/_pytest/_py/path.py:299:5: RUF050 Wrong statement inside class definition
+ src/_pytest/assertion/rewrite.py:292:5: RUF050 Wrong statement inside class definition
+ src/_pytest/config/argparsing.py:450:5: RUF050 Wrong statement inside class definition
+ src/_pytest/doctest.py:511:13: RUF050 Wrong statement inside class definition
+ src/_pytest/doctest.py:533:13: RUF050 Wrong statement inside class definition
+ src/_pytest/doctest.py:551:13: RUF050 Wrong statement inside class definition
+ src/_pytest/mark/structures.py:505:5: RUF050 Wrong statement inside class definition
+ src/_pytest/pytester.py:243:5: RUF050 Wrong statement inside class definition
+ src/_pytest/reports.py:69:5: RUF050 Wrong statement inside class definition
... 2 additional changes omitted for project

... Truncated remaining completed project reports due to GitHub comment length restrictions

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
RUF050 245 245 0 0 0

@Lokejoke Lokejoke marked this pull request as ready for review November 26, 2024 13:43
@MichaReiser
Copy link
Member

This seems more common than I expected: A few findings from clicking through the ecosystem results:

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule needs-decision Awaiting a decision from a maintainer labels Nov 26, 2024
@AlexWaygood
Copy link
Member

AlexWaygood commented Nov 26, 2024

I'm not sure we should accept this right now :/ I just don't really agree with the premise of the rule. There are lots of reasons why you might need to use a wider range of syntax than the very small selection this rule permits. To me, it seems like a very opinionated restriction rule that would be very noisy for a lot of our users and would have to be entirely disabled on many codebases.

@MichaReiser
Copy link
Member

Thanks @AlexWaygood. This makes sense to me. Sorry @Lokejoke. We can reconsider adding this rule once we have a better framework for more opinionated rules, see #1774

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants