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

Implement EntryPoint as a simple object (remove namedtuple) #339

Merged
merged 5 commits into from Aug 29, 2021

Conversation

jaraco
Copy link
Member

@jaraco jaraco commented Aug 13, 2021

Fixes #337 by eschewing the namedtuple superclass. Allows for removal of PyPy workaround and incidental namedtuple interfaces.

@jaraco jaraco changed the base branch from main to maint/3.8.x August 13, 2021 22:38
@jaraco jaraco changed the base branch from maint/3.8.x to main August 13, 2021 22:38
@jaraco jaraco force-pushed the feature/337-EntryPoint-object branch from 3ab8f91 to 2eca591 Compare August 13, 2021 22:47
@@ -159,6 +156,9 @@ class EntryPoint(

dist: Optional['Distribution'] = None

def __init__(self, *, name, value, group):
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend going for explicit assignment here for the sake of readability and setting self.dist as well

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd actually like to keep the name/group/value as the essential attributes separate from the dist, which is optional and auxiliary. Agree with explicit assignment. I'm not sure it's possible.

importlib_metadata/__init__.py Outdated Show resolved Hide resolved
importlib_metadata/__init__.py Show resolved Hide resolved
importlib_metadata/__init__.py Show resolved Hide resolved
Co-authored-by: Ronny Pfannschmidt <opensource@ronnypfannschmidt.de>
@jaraco jaraco mentioned this pull request Aug 26, 2021
@jaraco
Copy link
Member Author

jaraco commented Aug 29, 2021

I'm a little reluctant to move forward with this implementation primarily because of concerns about compatibility. This change removes the ability to construct EntryPoint objects from three positional args. I'm debating whether this change can be introduced without supporting that interface, or if the positional args is worth retaining, or if it should be deprecated.

I'm aiming for "preferably one obvious way" to initialize an EntryPoint to limit the support surface. I'm even tempted to disallow construction of EntryPoint objects altogether.

Maybe the best approach is to implement a simple constructor, retain compatibility, and consider constraining the interface later. Edit: This approach is the one this PR enacts, attempting to retain compatibility.

@jaraco jaraco merged commit fa620f1 into main Aug 29, 2021
@jaraco jaraco deleted the feature/337-EntryPoint-object branch August 29, 2021 03:18
@mr-c
Copy link

mr-c commented Aug 29, 2021

Hello, this change broke stevedore which broke bandit for at least myself (but probably others)

https://github.com/common-workflow-language/cwltool/pull/1482/checks?check_run_id=3454232416#step:9:50
PyCQA/bandit#730

Reverting to importlib_metadata version 4.7.1 resolves the problem for me

@jaraco jaraco changed the title Exploring EntryPoint as a simple object Implement EntryPoint as a simple object (remove namedtuple) Aug 29, 2021
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.

Entrypoint __iter__ implemementation breaks _asdict
3 participants