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

Drop formatting specific rules from the default set #7900

Merged
merged 2 commits into from
Oct 11, 2023
Merged

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Oct 10, 2023

Closes #7572

Drops formatting specific rules from the default rule set as they conflict with formatters in general (and in particular, conflict with our formatter). Most of these rules are in preview, but the removal of line-too-long and mixed-spaces-and-tabs is a change to the stable rule set.

Example

The following no longer raises E501

echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 1" | ruff check -

@zanieb zanieb added the breaking Breaking API change label Oct 10, 2023
Comment on lines -28 to -32
const DEFAULT_SELECTORS: &[RuleSelector] = &[
RuleSelector::Linter(Linter::Pyflakes),
RuleSelector::Linter(Linter::Pycodestyle),
];

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear if the flake8 converter needs a different default rule set than Ruff?

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 10, 2023

CodSpeed Performance Report

Merging #7900 will improve performances by 9.75%

Comparing zanie/default-rules (cd53a45) with main (090c1a4)

Summary

⚡ 4 improvements
✅ 21 untouched benchmarks

Benchmarks breakdown

Benchmark main zanie/default-rules Change
linter/default-rules[unicode/pypinyin.py] 6.3 ms 6.1 ms +4.74%
linter/default-rules[numpy/globals.py] 2.2 ms 2 ms +9.75%
linter/default-rules[numpy/ctypeslib.py] 18.6 ms 17.4 ms +6.99%
linter/default-rules[pydantic/types.py] 38.8 ms 36.8 ms +5.58%

@github-actions
Copy link
Contributor

github-actions bot commented Oct 10, 2023

PR Check Results

Ecosystem

ℹ️ ecosystem check detected changes. (+0, -88, 0 error(s))

setuptools (+0, -88)

- pkg_resources/_vendor/platformdirs/__init__.py:109:89: E501 Line too long (115 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:125:89: E501 Line too long (110 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:141:89: E501 Line too long (110 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:157:89: E501 Line too long (108 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:180:89: E501 Line too long (112 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:196:89: E501 Line too long (110 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:212:89: E501 Line too long (114 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:228:89: E501 Line too long (112 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:244:89: E501 Line too long (116 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:260:89: E501 Line too long (111 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:276:89: E501 Line too long (111 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:292:89: E501 Line too long (109 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:2:89: E501 Line too long (119 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:315:89: E501 Line too long (113 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:61:89: E501 Line too long (109 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:77:89: E501 Line too long (113 > 88 characters)
- pkg_resources/_vendor/platformdirs/__init__.py:93:89: E501 Line too long (111 > 88 characters)
- pkg_resources/_vendor/platformdirs/android.py:111:89: E501 Line too long (107 > 88 characters)
- pkg_resources/_vendor/platformdirs/android.py:14:89: E501 Line too long (100 > 88 characters)
- pkg_resources/_vendor/platformdirs/android.py:21:89: E501 Line too long (114 > 88 characters)
- pkg_resources/_vendor/platformdirs/android.py:32:89: E501 Line too long (117 > 88 characters)
- pkg_resources/_vendor/platformdirs/android.py:34:89: E501 Line too long (94 > 88 characters)
- pkg_resources/_vendor/platformdirs/android.py:43:89: E501 Line too long (120 > 88 characters)
- pkg_resources/_vendor/platformdirs/android.py:54:89: E501 Line too long (112 > 88 characters)
- pkg_resources/_vendor/platformdirs/android.py:65:89: E501 Line too long (92 > 88 characters)
- pkg_resources/_vendor/platformdirs/android.py:72:89: E501 Line too long (116 > 88 characters)
- pkg_resources/_vendor/platformdirs/api.py:39:89: E501 Line too long (119 > 88 characters)
- pkg_resources/_vendor/platformdirs/api.py:44:89: E501 Line too long (120 > 88 characters)
- pkg_resources/_vendor/platformdirs/api.py:45:89: E501 Line too long (106 > 88 characters)
- pkg_resources/_vendor/platformdirs/api.py:49:89: E501 Line too long (117 > 88 characters)
- pkg_resources/_vendor/platformdirs/api.py:55:89: E501 Line too long (119 > 88 characters)
- pkg_resources/_vendor/platformdirs/macos.py:10:89: E501 Line too long (103 > 88 characters)
- pkg_resources/_vendor/platformdirs/macos.py:18:89: E501 Line too long (112 > 88 characters)
- pkg_resources/_vendor/platformdirs/macos.py:19:89: E501 Line too long (102 > 88 characters)
- pkg_resources/_vendor/platformdirs/macos.py:23:89: E501 Line too long (110 > 88 characters)
- pkg_resources/_vendor/platformdirs/macos.py:28:89: E501 Line too long (106 > 88 characters)
- pkg_resources/_vendor/platformdirs/macos.py:29:89: E501 Line too long (94 > 88 characters)
- pkg_resources/_vendor/platformdirs/macos.py:33:89: E501 Line too long (99 > 88 characters)
- pkg_resources/_vendor/platformdirs/macos.py:38:89: E501 Line too long (100 > 88 characters)
- pkg_resources/_vendor/platformdirs/macos.py:48:89: E501 Line too long (96 > 88 characters)
- pkg_resources/_vendor/platformdirs/macos.py:58:89: E501 Line too long (117 > 88 characters)
- pkg_resources/_vendor/platformdirs/macos.py:59:89: E501 Line too long (103 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:10:89: E501 Line too long (104 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:110:89: E501 Line too long (111 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:133:89: E501 Line too long (101 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:143:89: E501 Line too long (114 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:148:89: E501 Line too long (120 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:21:89: E501 Line too long (119 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:22:89: E501 Line too long (118 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:33:89: E501 Line too long (94 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:44:89: E501 Line too long (113 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:45:89: E501 Line too long (115 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:46:89: E501 Line too long (105 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:58:89: E501 Line too long (97 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:64:89: E501 Line too long (91 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:75:89: E501 Line too long (112 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:76:89: E501 Line too long (118 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:88:89: E501 Line too long (89 > 88 characters)
- pkg_resources/_vendor/platformdirs/unix.py:99:89: E501 Line too long (95 > 88 characters)
- pkg_resources/_vendor/platformdirs/windows.py:136:89: E501 Line too long (112 > 88 characters)
- pkg_resources/_vendor/platformdirs/windows.py:140:89: E501 Line too long (119 > 88 characters)
- pkg_resources/_vendor/platformdirs/windows.py:48:89: E501 Line too long (101 > 88 characters)
- pkg_resources/_vendor/platformdirs/windows.py:65:89: E501 Line too long (113 > 88 characters)
- pkg_resources/_vendor/platformdirs/windows.py:79:89: E501 Line too long (111 > 88 characters)
- pkg_resources/_vendor/platformdirs/windows.py:99:89: E501 Line too long (92 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:1080:89: E501 Line too long (89 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:1139:89: E501 Line too long (89 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:1410:89: E501 Line too long (89 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:162:89: E501 Line too long (89 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:1726:89: E501 Line too long (90 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:1743:89: E501 Line too long (90 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:1811:89: E501 Line too long (90 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:2149:89: E501 Line too long (89 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:2178:89: E501 Line too long (89 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:2182:89: E501 Line too long (89 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:629:89: E501 Line too long (89 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:689:89: E501 Line too long (89 > 88 characters)
- pkg_resources/_vendor/typing_extensions.py:968:89: E501 Line too long (89 > 88 characters)
- setuptools/_vendor/more_itertools/more.py:3456:89: E501 Line too long (99 > 88 characters)
- setuptools/_vendor/typing_extensions.py:1006:89: E501 Line too long (89 > 88 characters)
- setuptools/_vendor/typing_extensions.py:1155:89: E501 Line too long (89 > 88 characters)
- setuptools/_vendor/typing_extensions.py:1512:89: E501 Line too long (89 > 88 characters)
- setuptools/_vendor/typing_extensions.py:1755:89: E501 Line too long (89 > 88 characters)
- setuptools/_vendor/typing_extensions.py:752:89: E501 Line too long (90 > 88 characters)
- setuptools/_vendor/typing_extensions.py:951:89: E501 Line too long (89 > 88 characters)
- setuptools/config/_validate_pyproject/fastjsonschema_exceptions.py:17:89: E501 Line too long (139 > 88 characters)
- setuptools/config/_validate_pyproject/fastjsonschema_exceptions.py:20:89: E501 Line too long (91 > 88 characters)
- setuptools/config/_validate_pyproject/fastjsonschema_exceptions.py:21:89: E501 Line too long (111 > 88 characters)

Rules changed: 1
Rule Changes Additions Removals
E501 88 0 88

@zanieb
Copy link
Member Author

zanieb commented Oct 10, 2023

The performance win is an exciting upside.

@zanieb zanieb requested a review from charliermarsh October 10, 2023 19:57
Comment on lines 240 to +242
By default, Ruff enables Flake8's `E` and `F` rules. Ruff supports all rules from the `F` category,
and a [subset](https://docs.astral.sh/ruff/rules/#error-e) of the `E` category, omitting those
stylistic rules made obsolete by the use of an autoformatter, like
stylistic rules made obsolete by the use of a formatter, like
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey we already say we won't include these

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first and second sentence in the paragraph sound contradictory to me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How so?

Comment on lines 240 to +242
By default, Ruff enables Flake8's `E` and `F` rules. Ruff supports all rules from the `F` category,
and a [subset](https://docs.astral.sh/ruff/rules/#error-e) of the `E` category, omitting those
stylistic rules made obsolete by the use of an autoformatter, like
stylistic rules made obsolete by the use of a formatter, like
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first and second sentence in the paragraph sound contradictory to me

@zanieb zanieb merged commit 40cad44 into main Oct 11, 2023
16 checks passed
@zanieb zanieb deleted the zanie/default-rules branch October 11, 2023 16:29
zanieb added a commit that referenced this pull request Oct 12, 2023
zanieb added a commit that referenced this pull request Oct 12, 2023
zanieb added a commit that referenced this pull request Oct 12, 2023
@MichaReiser
Copy link
Member

Nice. Thank you for landing this change!

@g3rv4
Copy link

g3rv4 commented Nov 14, 2023

hi there :) I was trying to understand why after v0.1.0 I'm no longer seeing E501 errors on long lines, and based on the description this seems to be why.

is the idea not to raise E501 anymore using ruff? or am I missing some extra configuration to bring it back? I've been reading the documentation and couldn't find anything that has changed.

I'd expect

echo 'print({"a": 1, "b":2, "c":3, "d": 4, "e": 5, "f": 6, "g": 7, "h": 8, "i": 9, "j": 10, "k": 11, "l": 12})' | ruff check -

to raise E501

@charliermarsh
Copy link
Member

@g3rv4 -- You can still enable E501! It's just not part of the default rule set. If you're using pyproject.toml:

[tool.ruff]
extend-select = ["E501"]

Or, to re-enable all of the E-class rules:

[tool.ruff]
extend-select = ["E"]

@g3rv4
Copy link

g3rv4 commented Nov 14, 2023

@charliermarsh thanks! now I understand the change on the README :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking API change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change select default to F, E4, E7, E9
5 participants