Start applying ruff rules#698
Start applying ruff rules#698DimitriPapadopoulos wants to merge 23 commits intoMagicStack:masterfrom
Conversation
f5ed349 to
8fc45da
Compare
8fc45da to
fedcca4
Compare
b4fef39 to
a2b4145
Compare
fantix
left a comment
There was a problem hiding this comment.
Thank you for the PR! Yes, lets do it.
Do you still have your [tool.ruff] section in pyproject.toml? We should include that too I think.
| _Context = dict[str, Any] | ||
| _ExceptionHandler = Callable[[asyncio.AbstractEventLoop, _Context], Any] | ||
| _SSLContext = Union[bool, None, ssl.SSLContext] | ||
| _SSLContext = bool | ssl.SSLContext | None |
There was a problem hiding this comment.
Okay this would require we drop support for 3.8 and 3.9, and we should. Lemme do that with another PR.
There was a problem hiding this comment.
Strange, Ruff is supposed to read this:
Line 5 in 173e88c
and adapt to whatever version of Python defined by
requires-python. Not sure what happened here 🤔
There was a problem hiding this comment.
Yeah anyways, the fix is good! ❤️
There was a problem hiding this comment.
(It's probably because it's a pyi file instead of py; X|Y grammar in pyi files is actually supported by mypy/pyright on Python 3.9.)
|
I used |
Ohh rule per commit is definitely great! It's just so that future code could simply apply the same rules, adding a |
B009 Do not call `getattr` with a constant attribute value.
It is not any safer than normal property access.
EXE001 Shebang is present but file is not executable
Unnecessary `start` argument in `range`
PIE810 Call `startswith` once with a `tuple`
SLOT000 Subclasses of `str` should define `__slots__`
F401 imported but unused
PLC0208 Use a sequence type instead of a `set` when iterating over values
PLR1722 Use `sys.exit()` instead of `exit`
PLR5501 Use `elif` instead of `else` then `if`, to reduce indentation
PLR6201 Use a set literal when testing for membership
UP006 Use `dict` instead of `Dict` for type annotation UP006 Use `list` instead of `List` for type annotation
UP007 Use `X | Y` for type annotations
Unnecessary mode
UP020 Use builtin `open`
UP022 Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE`
UP024 Replace aliased errors with `OSError`
UP031 Use format specifiers instead of percent format
UP032 Use f-string instead of `format` call
UP045 Use `X | None` for type annotations
Use of regular expression alias
RUF036 `None` not at the end of the type annotation.
RUF046 Value being cast to `int` is already an integer
I have selected ruff rules that seem to make most sense. My idea is to suggest switching from flake8 to ruff.