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

Mark interfaces as Protocols and add missing self argument #4144

Merged
merged 3 commits into from Jan 24, 2024

Conversation

Avasam
Copy link
Contributor

@Avasam Avasam commented Nov 28, 2023

Summary of changes

This was noticed in https://github.com/python/typeshed/pull/10058/files#diff-1acb87d31f86c216cde10127dbe27643bd9d83975a757d3fe75559c03fd9b934

This change allows users to use these Protocols in static-type-checking to ensure proper usage of any class implementing these Interfaces.

Doesn't close any open issue, but relates to/work towards #2345

Pull Request Checklist

@Avasam Avasam force-pushed the pkg_resources-invalid-protocols branch from dbc0eb4 to 2f7156d Compare November 28, 2023 20:57
@Avasam Avasam force-pushed the pkg_resources-invalid-protocols branch from 2f7156d to f73efcc Compare November 28, 2023 21:16
@Avasam Avasam mentioned this pull request Jan 12, 2024
2 tasks
"""Execute the named script in the supplied namespace dictionary"""


class IResourceProvider(IMetadataProvider):
class IResourceProvider(IMetadataProvider, Protocol):
Copy link
Member

Choose a reason for hiding this comment

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

Today I learned about extending protocols. Nice work.

@@ -544,54 +545,54 @@ def get_entry_info(dist, group, name):
return get_distribution(dist).get_entry_info(group, name)


class IMetadataProvider:
def has_metadata(name):
class IMetadataProvider(Protocol):
Copy link
Member

Choose a reason for hiding this comment

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

I have no idea if these protocols are used anywhere (such as with Zope), but I suspect not. If this change ends up causing unexpected disruption, we may have to back it out. Thanks for making it a separate PR.

@jaraco jaraco merged commit 04a6bfe into pypa:main Jan 24, 2024
23 checks passed
@Avasam Avasam deleted the pkg_resources-invalid-protocols branch January 24, 2024 18:58
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