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

Automatic updates from Ruff for Python 3.9+ #4721

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

abravalheri
Copy link
Contributor

@abravalheri abravalheri commented Oct 31, 2024

Summary of changes

Implement @Avasam suggestions from #4718 (comment):

  • functools.lru_cache(maxsize=None) can be replaced by functools.cache
  • Callable, Generator, Iterator, Iterable, Sequence, Mapping, MutableMapping should be imported from collections.abc instead of typing
  • Type, Dict, List, Tuple should be replaced by their builtin variant

The procedure used for the changes is:

  1. Modify ruff.toml as suggested in Remove unnecessary code paths for 3.9+ (follow up on skeleton changes) #4718 (comment)
  2. Run ruff check --fix --unsafe-fixes
  3. Manually add the missing fixes
  4. Manually check all files and add improvements as necessary
  5. git restore ruff.toml (I am leaving this decision for skeleton for the time being)
  6. git restore setuptools/_importlib.py (Already covered in Remove unnecessary code paths for 3.9+ (follow up on skeleton changes) #4718)

Pull Request Checklist

@Avasam
Copy link
Contributor

Avasam commented Oct 31, 2024

Idk if we want the F841 preview of removing/marking unused variables ?
As in, it's not a 3.8 -> 3.9 change, but rather caused by setuptool's Ruff configs not using preview behaviour by default for the linter (preview is enabled for the formatter).

@abravalheri
Copy link
Contributor Author

Idk if we want the F841 preview of removing/marking unused variables ? As in, it's not a 3.8 -> 3.9 change, but rather caused by setuptool's Ruff configs not using preview behaviour by default for the linter (preview is enabled for the formatter).

You are right. I should, at least, separate it into to 2 PRs. I will have a look at it later, thank you.

@abravalheri abravalheri changed the title (Mostly) automatic updates from Ruff for Python 3.9+ Automatic updates from Ruff for Python 3.9+ Oct 31, 2024
@abravalheri
Copy link
Contributor Author

Removed the changes for F841

@abravalheri
Copy link
Contributor Author

This thing of pypy jobs randomly being cancelled by GHA is becoming inconvenient.

@Avasam
Copy link
Contributor

Avasam commented Nov 1, 2024

I was surprised that Ruff didn't also move Callable. Apparently there's runtime issues with Callable and generic params in 3.9.0 and 3.9.1.
astral-sh/ruff#2690
I'll assume setuptools aims at supporting all patch versions if possible. If so, Ruff is right and no manual change needed ! (at least when not used in an annotation with from __future__ import annotations)

@abravalheri
Copy link
Contributor Author

Perfect, thank you very much @Avasam, for the thorough review.

I think from this set of PRs, the only controversial one is the one I remove the vendored copy of importlib_resources, so I am waiting a little bit before merging that one.

But we should be able to merge this PR with relatively ease.

Copy link
Contributor

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

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

The typing looks fine and is 3.9 compatible 👍🏻

@abravalheri abravalheri merged commit 832c850 into pypa:main Nov 4, 2024
20 of 24 checks passed
@abravalheri abravalheri deleted the more-3.9-updates branch November 4, 2024 13:06
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