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

Defining a method called "format" on an enum triggers incorrect errors #7787

Open
ruuda opened this issue Oct 24, 2019 · 1 comment
Open
Labels
bug mypy got something wrong priority-2-low

Comments

@ruuda
Copy link

ruuda commented Oct 24, 2019

Please provide more information to help us understand the issue:

  • Are you reporting a bug, or opening a feature request? I am reporting a bug.

  • Please insert below the code you are checking with mypy.

    from enum import Enum, auto
    
    class Widget(Enum):
        vanilla = auto()
        chocolate = auto()
    
        def format(self, n: int) -> str:
            return f'{self.name} {n}'
    
    print(Widget.vanilla.format(10))
  • What is the actual behavior/output?

    repro.py:10: error: Not all arguments converted during string formatting
    Found 1 error in 1 file (checked 1 source file)
    

    This happens at the call to format.

  • What is the behavior/output you expect? The file should typecheck without errors.

  • What are the versions of mypy and Python you are using? Mypy 0.740 on Python 3.7.5.
    Do you see the same issue after installing mypy from Git master? Yes, on 09c1fc7 the problem is still present.

  • What are the mypy flags you are using? None, just the default.

Issue #7563 seemed superficially related, but now that I am taking a closer look, I’m not sure any more.

@ilevkivskyi
Copy link
Member

Yes, this looks like a separate issue. I think this is relatively low priority.

@ilevkivskyi ilevkivskyi added bug mypy got something wrong priority-2-low labels Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-2-low
Projects
None yet
Development

No branches or pull requests

2 participants