Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Automatic updates from Ruff for Python 3.9+#4721

Merged
abravalheri merged 1 commit into
pypa:mainfrom
abravalheri:more-3.9-updates
Nov 4, 2024
Merged

Automatic updates from Ruff for Python 3.9+#4721
abravalheri merged 1 commit into
pypa:mainfrom
abravalheri:more-3.9-updates

Conversation

@abravalheri

@abravalheri abravalheri commented Oct 31, 2024

Copy link
Copy Markdown
Contributor

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

Avasam commented Oct 31, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor Author

Removed the changes for F841

@abravalheri

Copy link
Copy Markdown
Contributor Author

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

@Avasam

Avasam commented Nov 1, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

@cdce8p cdce8p left a comment

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.

The typing looks fine and is 3.9 compatible 👍🏻

@abravalheri abravalheri merged commit 832c850 into pypa:main Nov 4, 2024
@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