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

Prevent a TypeError in compat.py311.shutil_rmtree #4382

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

Avasam
Copy link
Contributor

@Avasam Avasam commented May 22, 2024

Summary of changes

Noticed while adding pyright checks to setuptools (#4192)
Also typed shutil_rmtree (xref python/typeshed#12002 )

Pull Request Checklist

Copy link
Contributor

@abravalheri abravalheri 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 very much for working on the type improvements of Setuptools.

I am a bit shocked with the amount of overhead this particular PR adds, is there anyway we can simplify it?

Is there anyway we can simplify this?

setuptools/compat/py311.py Outdated Show resolved Hide resolved
setuptools/compat/py311.py Outdated Show resolved Hide resolved
Comment on lines +5 to +8
from typing import Any, Callable, TYPE_CHECKING

if TYPE_CHECKING:
from _typeshed import StrOrBytesPath, ExcInfo
Copy link
Contributor Author

@Avasam Avasam May 24, 2024

Choose a reason for hiding this comment

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

Is there anyway we can simplify this?

The runtime fix is just the added conditional. Everything else is type hints.

I just combined imports. I could omit annotating the internal function and move StrOrBytesPath to a runtime alias with StrPath in setuptools._path.

@Avasam Avasam force-pushed the shutil-rmtree-None-onexc branch from 5b9d6c7 to 040ea9e Compare May 24, 2024 19:08
…rmtree`is called without an`onexc`` parameter on Python<=3.11
@Avasam Avasam force-pushed the shutil-rmtree-None-onexc branch from 040ea9e to 6e4cf9f Compare May 24, 2024 19:28
@Avasam Avasam requested a review from abravalheri June 12, 2024 16:40
@abravalheri abravalheri merged commit 5ed52c1 into pypa:main Jun 17, 2024
20 of 22 checks passed
@Avasam Avasam deleted the shutil-rmtree-None-onexc branch June 17, 2024 15:20
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