-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugmypy got something wrongmypy got something wrong
Description
I'm trying to stub a function that takes different types for a base argument and then a bunch of AnyStrs. It seems that neither Union nor overload works correctly for stubbing it:
from typing import overload, AnyStr, Union
def f(x: Union[AnyStr, int], *a: AnyStr) -> None: ...
@overload
def g(x: AnyStr, *a: AnyStr) -> None: ...
@overload
def g(x: int, *a: AnyStr) -> None: ...
f('foo')
f('foo', 'bar')
f('foo', b'bar') # correctly fails: Type argument 1 of "f" has incompatible value "object"
f(1) # erroneously fails: error: Type argument 1 of "f" has incompatible value "int"
f(1, 'foo') # erroneously fails: error: Type argument 1 of "f" has incompatible value "object"
f(1, 'foo', b'bar') # correctly fails: error: Type argument 1 of "f" has incompatible value "object"
g('foo')
g('foo', 'bar')
g('foo', b'bar') # correctly fails: error: Type argument 1 of "g" has incompatible value "object"
g(1)
g(1, 'foo') # erroneously fails: error: Type argument 1 of "g" has incompatible value "object"
g(1, 'foo', b'bar') # correctly fails: Type argument 1 of "g" has incompatible value "object"
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong