-
-
Notifications
You must be signed in to change notification settings - Fork 424
Mypy false positive for union validator #1336
Copy link
Copy link
Closed
Labels
TypingTyping/stub/Mypy/PyRight related bugs.Typing/stub/Mypy/PyRight related bugs.
Description
Not sure if this is a duplicate but I couldn't find the problem in the open issues. If I overlooked it, please close, of course.
from attrs import define, field
from attrs.validators import instance_of
LeTypeAlias = int | str
@define
class LeClass:
x: LeTypeAlias = field(validator=instance_of(LeTypeAlias))Works perfectly but mypy complains about:
error: No overload variant of "instance_of" matches argument type "UnionType[int, str]" [call-overload]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
TypingTyping/stub/Mypy/PyRight related bugs.Typing/stub/Mypy/PyRight related bugs.