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

Mypy false positive for union validator #1336

Open
AdrianSosic opened this issue Aug 16, 2024 · 1 comment
Open

Mypy false positive for union validator #1336

AdrianSosic opened this issue Aug 16, 2024 · 1 comment
Labels
Typing Typing/stub/Mypy/PyRight related bugs.

Comments

@AdrianSosic
Copy link

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]
@hynek hynek added the Typing Typing/stub/Mypy/PyRight related bugs. label Aug 17, 2024
@hynek
Copy link
Member

hynek commented Aug 17, 2024

That doesn’t sound familiar and should be easy to fix. 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing Typing/stub/Mypy/PyRight related bugs.
Projects
None yet
Development

No branches or pull requests

2 participants