Closed
Description
Hi,
- Are you reporting a bug, or opening a feature request?
Reporting a minor bug in--strict
mode when adding private property to Enum subclass.
import operator
import enum
from typing import Callable
@enum.unique
class Comparator(enum.Enum):
LessThan = "<"
LessThanOrEqualTo = "<="
EqualTo = "=="
NotEqualTo = "!="
GreaterThanOrEqualTo = ">="
GreaterThan = ">"
__operator__ = {
LessThan: operator.lt,
LessThanOrEqualTo: operator.le,
EqualTo: operator.eq,
NotEqualTo: operator.ne,
GreaterThanOrEqualTo: operator.ge,
GreaterThan: operator.gt
}
@property
def operator(self) -> Callable[[object, object], bool]:
return Comparator.__operator__[self.value]
Comparator.LessThan.operator(1,2)
Comparator("<").operator(1,2)
- What is the actual behavior/output?
The output is the following, where the first line is a missing stub foroperator
, and the second is the error in this report:
<string>:26: warning: Returning Any from function declared to return "Callable[[object, object], bool]"
<string>:26: error: Value of type "Comparator" is not indexable
-
What is the behavior/output you expect?
<string>:26: error: Value of type "Comparator" is not indexable
should not appear. -
What are the versions of mypy and Python you are using?
mypy: 0.610
python: 3.6.5
Could not run mypy from master -
What are the mypy flags you are using? (For example --strict-optional)
--strict