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

Broken mypy support #351

Closed
chrisjsewell opened this issue Aug 30, 2021 · 1 comment
Closed

Broken mypy support #351

chrisjsewell opened this issue Aug 30, 2021 · 1 comment
Labels
question Further information is requested

Comments

@chrisjsewell
Copy link

chrisjsewell commented Aug 30, 2021

Heya, after this commit: 29ec9c3,
mypy (and I imagine other static analysers) can no longer determine that the EntryPoint has name, value and group attributes.

Was there a reason for doing this:

    def __init__(self, *, name, value, group):
        vars(self).update(name=name, value=value, group=group)

rather than the conventional

    def __init__(self, *, name, value, group):
        self.name = name
        self.value = value
        self.group = group
@jaraco
Copy link
Member

jaraco commented Sep 13, 2021

Was there a reason for doing this

Yes. You can try making that change and you'll see the tests fail. __setattr__ is overridden to make the object immutable.

I'd really like to see the mypy add support similar to NamedTuple for this use-case.

Do you know of a way to fix this issue? I know in #342, Anders is working on enabling strict type checking on this project. But that issue is currently blocked on mypy being unable to support dynamic constructs like always_iterable and rebasing on this recent refactor.

Perhaps the reported issue here could be solved by adding type directives to the class properties, but without a repro, I'm not even sure how to test for expected behavior.

Feel free to follow up with a repro or proposed patch. In the meantime, I'll close this as answered.

@jaraco jaraco closed this as completed Sep 13, 2021
@jaraco jaraco added the question Further information is requested label Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants