Skip to content

Start applying ruff rules#698

Open
DimitriPapadopoulos wants to merge 23 commits intoMagicStack:masterfrom
DimitriPapadopoulos:ruff
Open

Start applying ruff rules#698
DimitriPapadopoulos wants to merge 23 commits intoMagicStack:masterfrom
DimitriPapadopoulos:ruff

Conversation

@DimitriPapadopoulos
Copy link
Copy Markdown
Contributor

I have selected ruff rules that seem to make most sense. My idea is to suggest switching from flake8 to ruff.

Copy link
Copy Markdown
Member

@fantix fantix left a comment

Choose a reason for hiding this comment

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

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.

Comment thread uvloop/loop.pyi
_Context = dict[str, Any]
_ExceptionHandler = Callable[[asyncio.AbstractEventLoop, _Context], Any]
_SSLContext = Union[bool, None, ssl.SSLContext]
_SSLContext = bool | ssl.SSLContext | None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay this would require we drop support for 3.8 and 3.9, and we should. Lemme do that with another PR.

Copy link
Copy Markdown
Contributor Author

@DimitriPapadopoulos DimitriPapadopoulos May 4, 2026

Choose a reason for hiding this comment

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

Strange, Ruff is supposed to read this:

requires-python = '>=3.8.1'

and adapt to whatever version of Python defined by requires-python. Not sure what happened here 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah anyways, the fix is good! ❤️

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(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.)

Comment thread tests/test_process_spawning.py
@DimitriPapadopoulos
Copy link
Copy Markdown
Contributor Author

I used --extend-select/--select to apply a single rule per commit, in case you wouldn't like a specififc rule. But I can add a [tool.ruff] section, no problem.

@fantix
Copy link
Copy Markdown
Member

fantix commented May 4, 2026

I used --extend-select/--select to apply a single rule per commit, in case you wouldn't like a specififc rule. But I can add a [tool.ruff] section, no problem.

Ohh rule per commit is definitely great! It's just so that future code could simply apply the same rules, adding a [tool.ruff] would be necessary? But we can do that in a second PR to replace test_flake8 with test_ruff

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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants