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 linter #537

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Ruff linter #537

wants to merge 3 commits into from

Conversation

CompRhys
Copy link

Addresses #534. Much faster linting and formatting using 1 tool as opposed to 3.

@ilyes319
Copy link
Contributor

ilyes319 commented Aug 5, 2024

Hey @CompRhys, looking at your changes, some of them will break compatibility with Python version 3.7 and 3.8.

@CompRhys
Copy link
Author

CompRhys commented Aug 5, 2024

I ran with target-version = "py37" and so I would assume that nothing would be broken. If you want to keep backwards compatibility to 3.7 would you take a PR adding a CI matrix as I shouldn't be installing an end-of-life python version without security fixes on work laptop?

@ilyes319
Copy link
Contributor

ilyes319 commented Aug 5, 2024

I think these kind of type hints: str | Path | None are not supported with older python versions. Why do you want to change the way we do type hints?

@janosh
Copy link
Contributor

janosh commented Aug 5, 2024

I think these kind of type hints: str | Path | None are not supported with older python versions.

they are actually, if you add from __future__ import annotations to the start of a module (inserting that import can be automated with ruff). it backports the leaner type annotations to 3.7

@ilyes319
Copy link
Contributor

ilyes319 commented Aug 5, 2024

Good to know. Is there any guidelines from Python to prefere these kind of annotations?

@CompRhys
Copy link
Author

CompRhys commented Aug 5, 2024

The pep for it was https://peps.python.org/pep-0604/ generally I think the preference has been to move towards not needing to explicitly import anything in order to type hint standard types such as list, str or combinations thereof.

@janosh
Copy link
Contributor

janosh commented Aug 5, 2024

Is there any guidelines from Python to prefer these kind of annotations?

yes, from __future__ import annotations is only necessary below 3.10. above, the new syntaxes works without side-effect imports which is part of python's move to enable more type safety

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.

3 participants