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

pkg_resources: Runtime fixes to make typing annotations work #4262

Merged

Conversation

Avasam
Copy link
Contributor

@Avasam Avasam commented Mar 6, 2024

Summary of changes

Should fix the last errors in #4246. These are all actual code changes, please review carefully.

Pull Request Checklist

@Avasam Avasam changed the title pkg_resoruces: Runtime fixes to make typing annotations work pkg_resources: Runtime fixes to make typing annotations work Mar 7, 2024
pkg_resources/__init__.py Show resolved Hide resolved
@@ -2825,7 +2825,7 @@ def activate(self, path=None, replace=False):
if path is None:
path = sys.path
self.insert_on(path, replace=replace)
if path is sys.path:
if path is sys.path and self.location:
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it is possible that self.location is an empty string...
The empty string is a valid entry for sys.path (and holds special meaning).

Copy link
Contributor Author

@Avasam Avasam Mar 8, 2024

Choose a reason for hiding this comment

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

Just in case:

Suggested change
if path is sys.path and self.location:
if path is sys.path and self.location is not None:

But I am unsure if we should raise early or gracefully "do nothing" on None

pkg_resources/__init__.py Outdated Show resolved Hide resolved
@Avasam Avasam requested a review from abravalheri April 21, 2024 20:26
@abravalheri abravalheri merged commit 6dc694e into pypa:main May 7, 2024
20 of 22 checks passed
@abravalheri
Copy link
Contributor

Thank you very much @Avasam.

@Avasam Avasam deleted the pkg_resoruces-typign-fixes-for-annotations branch May 7, 2024 18:17
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

2 participants