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

Enforce modern annotations syntax #4368

Merged
merged 3 commits into from
Jun 17, 2024
Merged

Conversation

Avasam
Copy link
Contributor

@Avasam Avasam commented May 18, 2024

Summary of changes

Relates to #2345 (comment) , as more type hints and annotations are added. Using a modern annotations syntax is preferable, reduces extraneous typing imports and allows more type subscriptions.

I've merged the ignore and extend-ignore ignore entries in Ruff because extend-ignore is obsolete https://docs.astral.sh/ruff/settings/#lint_extend-ignore

Bumped ruff in pre-commit to latest.
Bumped pytest-ruff to latest (https://github.com/businho/pytest-ruff/releases/tag/v0.3.2 should have a much cleaner error output now)
Edit: I keep forgetting this comes from the skeleton, I opened jaraco/skeleton#126

Pull Request Checklist

  • Changes have tests (added new lint checks)
  • News fragment added in newsfragments/. (no user-facing changes)
    (See documentation for details)

@DimitriPapadopoulos
Copy link
Contributor

Perhaps bump ruff version to 0.4.4:

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.8

@Avasam
Copy link
Contributor Author

Avasam commented May 21, 2024

setuptools/.pre-commit-config.yaml

Is pre-commit.ci even enabled in this project? It'd be nice to for autofixes on PRs (including lint fixes which that config is missing).

either way yeah, let's bump Ruff too

@DimitriPapadopoulos
Copy link
Contributor

You-re right, pre-commit does not seem to be used by CI jobs, instead something (tox?) calls pytest-ruff.

Conflicts must be resolved.

@Avasam
Copy link
Contributor Author

Avasam commented May 24, 2024

Runtime type aliases can't use | unions for Python 3.8 . In those cases, would you prefer Union[..., None] or Optional[...] ? Personally I feel like the former, avoiding Optional, will be more consistent (in terms of imports, avoids Optional[Union[..., ...]] and closer to eventual syntax upgrade)

@abravalheri
Copy link
Contributor

Union[..., None] should be fine, specially if it simplifies Optional[Union[..., ...]]...

@abravalheri abravalheri merged commit a001ec8 into pypa:main Jun 17, 2024
22 checks passed
@abravalheri
Copy link
Contributor

Thank you!

@Avasam Avasam deleted the future-annotations branch June 17, 2024 17:04
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.

None yet

3 participants