Skip to content

Broken mypy support #351

Closed
Closed

Description

@chrisjsewell

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

Activity

  1. jaraco commented on Sep 13, 2021

    @jaraco
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions