Skip to content

Commit ead9d11

Browse files
committed
Fix tests
1 parent 70300d3 commit ead9d11

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

test-data/unit/check-functions.test

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,11 +2075,29 @@ def f(x: AnyStr, y: AnyStr) -> None: pass
20752075
def g(x: AnyStr, y: AnyStr, z: int) -> None: pass
20762076
f('a', 'b')
20772077
f(b'a', b'b')
2078-
f('a', b'b') # E: Type arguments of "f" have incompatible values with expected ('AnyStr', 'AnyStr') \
2078+
f('a', b'b') # E: Type arguments of "f('AnyStr', 'AnyStr')" have incompatible values \
20792079
# N: "AnyStr" arguments must be all "str" or all "bytes"
20802080
g('a', 'b', 1)
2081-
g('a', b'b', 1) # E: Type arguments of "g" have incompatible values with expected ('AnyStr', 'AnyStr', 'int') \
2081+
g('a', b'b', 1) # E: Type arguments of "g('AnyStr', 'AnyStr', 'int')" have incompatible values \
20822082
# N: "AnyStr" arguments must be all "str" or all "bytes"
2083-
g('a', b'b', 'c') # E: Type arguments of "g" have incompatible values with expected ('AnyStr', 'AnyStr', 'int') \
2083+
g('a', b'b', 'c') # E: Type arguments of "g('AnyStr', 'AnyStr', 'int')" have incompatible values \
20842084
# N: "AnyStr" arguments must be all "str" or all "bytes" \
20852085
# E: Argument 3 to "g" has incompatible type "str"; expected "int"
2086+
2087+
[case testUnionAnyStrIncompatibleArguments]
2088+
from typing import TypeVar, Union
2089+
AnyStr = TypeVar('AnyStr', bytes, str)
2090+
def f(x: Union[AnyStr, int], y: AnyStr) -> None: pass
2091+
f('a', 'b')
2092+
f(1, 'b')
2093+
f('a', b'b') # E: Type arguments of "f('Union[AnyStr, int]', 'AnyStr')" have incompatible values \
2094+
# N: "AnyStr" arguments must be all "str" or all "bytes"
2095+
2096+
[case testStarAnyStrIncompatibleArguments]
2097+
from typing import TypeVar, Union
2098+
AnyStr = TypeVar('AnyStr', bytes, str)
2099+
def f(*x: AnyStr) -> None: pass
2100+
f('a')
2101+
f('a', 'b')
2102+
f('a', b'b') # E: Type arguments of "f('AnyStr')" have incompatible values \
2103+
# N: "AnyStr" arguments must be all "str" or all "bytes"

test-data/unit/check-inference.test

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,12 @@ AnyStr = TypeVar('AnyStr', bytes, str)
750750
def f(x: Union[AnyStr, int], *a: AnyStr) -> None: pass
751751
f('foo')
752752
f('foo', 'bar')
753-
f('foo', b'bar') # E: Type argument 1 of "f" has incompatible value "object"
753+
f('foo', b'bar') # E: Type arguments of "f('Union[AnyStr, int]', 'AnyStr')" have incompatible values \
754+
# N: "AnyStr" arguments must be all "str" or all "bytes"
754755
f(1)
755756
f(1, 'foo')
756-
f(1, 'foo', b'bar') # E: Type argument 1 of "f" has incompatible value "object"
757+
f(1, 'foo', b'bar') # E: Type arguments of "f('Union[AnyStr, int]', 'AnyStr')" have incompatible values \
758+
# N: "AnyStr" arguments must be all "str" or all "bytes"
757759
[builtins fixtures/primitives.pyi]
758760

759761

test-data/unit/check-overloading.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,11 +998,12 @@ def g(x: int, *a: AnyStr) -> None: pass
998998

999999
g('foo')
10001000
g('foo', 'bar')
1001-
g('foo', b'bar') # E: Type arguments of "g" have incompatible values with expected ('AnyStr', 'AnyStr') \
1001+
g('foo', b'bar') # E: Type arguments of "g('AnyStr', 'AnyStr')" have incompatible values \
10021002
# N: "AnyStr" arguments must be all "str" or all "bytes"
10031003
g(1)
10041004
g(1, 'foo')
1005-
g(1, 'foo', b'bar') # E: Type argument 1 of "g" has incompatible value "object"
1005+
g(1, 'foo', b'bar') # E: Type arguments of "g('int', 'AnyStr')" have incompatible values \
1006+
# N: "AnyStr" arguments must be all "str" or all "bytes"
10061007
[builtins fixtures/primitives.pyi]
10071008

10081009
[case testBadOverlapWithTypeVarsWithValues]

test-data/unit/pythoneval.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ re.subn(bpat, b'', b'')[0] + b''
12511251
re.subn(bre, lambda m: b'', b'')[0] + b''
12521252
re.subn(bpat, lambda m: b'', b'')[0] + b''
12531253
[out]
1254-
_program.py:7: error: Type arguments of "search" have incompatible values with expected ('AnyStr', 'AnyStr', 'int')
1254+
_program.py:7: error: Type arguments of "search('AnyStr', 'AnyStr', 'int')" have incompatible values
12551255
_program.py:7: note: "AnyStr" arguments must be all "str" or all "bytes"
12561256
_program.py:9: error: Cannot infer type argument 1 of "search"
12571257

@@ -1276,7 +1276,7 @@ re.subn(spat, '', '')[0] + ''
12761276
re.subn(sre, lambda m: '', '')[0] + ''
12771277
re.subn(spat, lambda m: '', '')[0] + ''
12781278
[out]
1279-
_program.py:7: error: Type arguments of "search" have incompatible values with expected ('AnyStr', 'AnyStr', 'int')
1279+
_program.py:7: error: Type arguments of "search('AnyStr', 'AnyStr', 'int')" have incompatible values
12801280
_program.py:7: note: "AnyStr" arguments must be all "str" or all "bytes"
12811281
_program.py:9: error: Cannot infer type argument 1 of "search"
12821282

0 commit comments

Comments
 (0)