-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Enable Ruff SIM #13309
base: main
Are you sure you want to change the base?
Enable Ruff SIM #13309
Changes from 3 commits
eee5ab1
a96249e
1daf81f
6126a6a
7d5868e
93d24f8
570c84c
892301b
818c0d3
b7e39ea
b40aa9b
c52feda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,10 +200,11 @@ def all_py_files_in_source_are_in_py_typed_dirs(source: zipfile.ZipFile | tarfil | |
if not all_python_files: | ||
return False | ||
|
||
for path in all_python_files: | ||
if not any(py_typed_dir in path.parents for py_typed_dir in py_typed_dirs): | ||
return False | ||
return True | ||
return all( | ||
# fmt: skip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed? This looks like how Black would format the code anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With our 130 line length black puts the whole thing on a single line. Which greatly affected readability. (Black and Ruff don't tend to have great vertical formatting for ternaries and comprehensions when the line length is long). For the sake of discussion about the "reimplemented-builtin (SIM110)" rule, I worked around this formatting issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you need to manually format the result, that seems like an argument against applying this "simplification" rule. |
||
any(py_typed_dir in path.parents for py_typed_dir in py_typed_dirs) | ||
for path in all_python_files | ||
) | ||
|
||
|
||
async def release_contains_py_typed(release_to_download: PypiReleaseDownload, *, session: aiohttp.ClientSession) -> bool: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,9 +240,7 @@ OP_SINGLE_ECDH_USE: int | |
OP_NO_COMPRESSION: int | ||
OP_ENABLE_MIDDLEBOX_COMPAT: int | ||
OP_NO_RENEGOTIATION: int | ||
if sys.version_info >= (3, 11): | ||
OP_IGNORE_UNEXPECTED_EOF: int | ||
elif sys.version_info >= (3, 8) and sys.platform == "linux": | ||
if sys.version_info >= (3, 11) or sys.platform == "linux": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
OP_IGNORE_UNEXPECTED_EOF: int | ||
if sys.version_info >= (3, 12): | ||
OP_LEGACY_SERVER_CONNECT: int | ||
|
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 still think I'd rather explicitly list the rules we think are useful here, rather than enabling the whole category and disabling specific rules. This category is just too hit-and-miss for me: some of the rules are pretty clear wins, but quite a few make some very opinionated suggestions that have high false-positive rates. Even if some of those rules don't have any false positives on typeshed today, there's a chance we might add code in the future that they'd emit false positives on, or there's a chance that Ruff might stabilise new
SIM
rules that have false positives on typeshed code.If lint rules end up irritating us (or confusing contributors) more than they actually help us write better code, then it defeats the purpose of a linter, in my opinion :-)
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.
Updated to be more specific about rules selection
I listed the rules I didn't select in the PR's description