I receive an unexpected error when running mypy related to a @classmethod exposed as @property of a class that inherits from Enum.
To Reproduce
from enum import Enum
from typing import List
class Stuff(Enum):
A = 'something'
B = 'something_else'
C = 'even_more'
@classmethod
@property
def important_stuff(cls) -> List[str]:
return [cls.A.value, cls.C.value]
print(f'{", ".join(Stuff.important_stuff)}')
Expected Behavior
As important_stuff always returns a list of strings, I would not expect any error to occur.
Actual Behavior
I receive an error
error: Argument 1 to "join" of "str" has incompatible type "Callable[[], List[str]]"; expected "Iterable[str]"
Your Environment
Mypy version used: 0.910
Mypy command-line flags: none
Mypy configuration options from mypy.ini (and other config files): none
Python version used: 3.9.5
Operating system and version: Ubuntu 20.04
The question was also asked on stackoverflow which also includes a workaround: click.
The text was updated successfully, but these errors were encountered:
willigott commentedFeb 1, 2022
Bug Report
I receive an unexpected error when running
mypy
related to a@classmethod
exposed as@property
of a class that inherits fromEnum
.To Reproduce
Expected Behavior
As
important_stuff
always returns a list of strings, I would not expect any error to occur.Actual Behavior
I receive an error
Your Environment
mypy.ini
(and other config files): noneThe question was also asked on stackoverflow which also includes a workaround: click.
The text was updated successfully, but these errors were encountered: