Skip to content

"Command Pattern" class causes unexpected error: Too many arguments #3807

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

Closed
Lordnibbler opened this issue Aug 7, 2017 · 1 comment
Closed

Comments

@Lordnibbler
Copy link

Lordnibbler commented Aug 7, 2017

I have a few command pattern classes, with a structure like this:

class Command(object):
    @classmethod
    def run(cls, string: str):
        cls('foo')

    def __init__(self, string: str) -> None:
        pass

The idea here is a clean class with a single class method to be invoked, ie. Command.run('foo').

Since adding mypy 0.521, I've noticed these errors pop up:

mypy ./command.py
command.py:4 error: Too many arguments for "Command" 

This can be resolved by placing the __init__ method before the run method, but I think one of two things should be done here:

  1. Make this error message clearer, explaining that an override of __init__ must come before a method that invokes it
  2. Ensure mypy correctly resolves the fact that __init__ is overridden here, and don't print this error.

Thoughts?

@ilevkivskyi
Copy link
Member

Thanks, I think this is a bug (false positive). But it looks like a duplicate of #1727. I am closing this one, and will instead raise priority of #1727 to normal.

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

No branches or pull requests

2 participants