Skip to content

Commit 9f7fbc1

Browse files
committed
fix tests
1 parent 4aea3fd commit 9f7fbc1

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

test-data/unit/check-fastparse.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ def f(a, # type: A
124124
**kwargs # type: F
125125
):
126126
reveal_type(a) # E: Revealed type is '__main__.A'
127-
reveal_type(b) # E: Revealed type is '__main__.B'
127+
reveal_type(b) # E: Revealed type is 'Union[__main__.B, builtins.None]'
128128
reveal_type(args) # E: Revealed type is 'builtins.tuple[__main__.C]'
129-
reveal_type(d) # E: Revealed type is '__main__.D'
129+
reveal_type(d) # E: Revealed type is 'Union[__main__.D, builtins.None]'
130130
reveal_type(e) # E: Revealed type is '__main__.E'
131131
reveal_type(kwargs) # E: Revealed type is 'builtins.dict[builtins.str, __main__.F]'
132132
[builtins fixtures/dict.pyi]
@@ -149,9 +149,9 @@ def f(a, # type: A
149149
):
150150
# type: (...) -> int
151151
reveal_type(a) # E: Revealed type is '__main__.A'
152-
reveal_type(b) # E: Revealed type is '__main__.B'
152+
reveal_type(b) # E: Revealed type is 'Union[__main__.B, builtins.None]'
153153
reveal_type(args) # E: Revealed type is 'builtins.tuple[__main__.C]'
154-
reveal_type(d) # E: Revealed type is '__main__.D'
154+
reveal_type(d) # E: Revealed type is 'Union[__main__.D, builtins.None]'
155155
reveal_type(e) # E: Revealed type is '__main__.E'
156156
reveal_type(kwargs) # E: Revealed type is 'builtins.dict[builtins.str, __main__.F]'
157157
return "not an int" # E: Incompatible return value type (got "str", expected "int")
@@ -191,7 +191,7 @@ def f(a, # type: A
191191
# kwargs not tested due to lack of 2.7 dict fixtures
192192
):
193193
reveal_type(a) # E: Revealed type is '__main__.A'
194-
reveal_type(b) # E: Revealed type is '__main__.B'
194+
reveal_type(b) # E: Revealed type is 'Union[__main__.B, builtins.None]'
195195
reveal_type(args) # E: Revealed type is 'builtins.tuple[__main__.C]'
196196
[builtins fixtures/dict.pyi]
197197
[out]
@@ -209,7 +209,7 @@ def f(a, # type: A
209209
):
210210
# type: (...) -> int
211211
reveal_type(a) # E: Revealed type is '__main__.A'
212-
reveal_type(b) # E: Revealed type is '__main__.B'
212+
reveal_type(b) # E: Revealed type is 'Union[__main__.B, builtins.None]'
213213
reveal_type(args) # E: Revealed type is 'builtins.tuple[__main__.C]'
214214
return "not an int" # E: Incompatible return value type (got "str", expected "int")
215215
[builtins fixtures/dict.pyi]

test-data/unit/check-flags.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,9 @@ import standard, optional
489489
[file standard.py]
490490
def f(x: int = None) -> None: pass
491491
[file optional.py]
492+
import standard
492493
def f(x: int = None) -> None: pass
494+
standard.f(None)
493495

494496
[file mypy.ini]
495497
[[mypy]

test-data/unit/check-functions.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ y = x # E: Incompatible types in assignment (expression has type Callable[...,
363363

364364
a, b = None, None # type: (A, B)
365365
a = f() # E: Incompatible types in assignment (expression has type "B", variable has type "A")
366-
b = f(b) # E: Argument 1 to "f" has incompatible type "B"; expected "A"
366+
b = f(b) # E: Argument 1 to "f" has incompatible type "B"; expected "Optional[A]"
367367
b = f(a, a) # E: Too many arguments for "f"
368368

369369
b = f()

test-data/unit/check-kwargs.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ f(a=A())
3030
f(b=B())
3131
f(c=C())
3232
f(b=B(), c=C())
33-
f(a=B()) # E: Argument 1 to "f" has incompatible type "B"; expected "A"
34-
f(b=A()) # E: Argument 1 to "f" has incompatible type "A"; expected "B"
35-
f(c=B()) # E: Argument 1 to "f" has incompatible type "B"; expected "C"
36-
f(b=B(), c=A()) # E: Argument 2 to "f" has incompatible type "A"; expected "C"
33+
f(a=B()) # E: Argument 1 to "f" has incompatible type "B"; expected "Optional[A]"
34+
f(b=A()) # E: Argument 1 to "f" has incompatible type "A"; expected "Optional[B]"
35+
f(c=B()) # E: Argument 1 to "f" has incompatible type "B"; expected "Optional[C]"
36+
f(b=B(), c=A()) # E: Argument 2 to "f" has incompatible type "A"; expected "Optional[C]"
3737
class A: pass
3838
class B: pass
3939
class C: pass
@@ -182,7 +182,7 @@ f(A(), b=B())
182182
f(A(), A(), b=B())
183183
f(B()) # E: Argument 1 to "f" has incompatible type "B"; expected "A"
184184
f(A(), B()) # E: Argument 2 to "f" has incompatible type "B"; expected "A"
185-
f(b=A()) # E: Argument 1 to "f" has incompatible type "A"; expected "B"
185+
f(b=A()) # E: Argument 1 to "f" has incompatible type "A"; expected "Optional[B]"
186186
class A: pass
187187
class B: pass
188188
[builtins fixtures/list.pyi]
@@ -197,8 +197,8 @@ f(b=B())
197197
f(*a, b=B())
198198
f(A(), *a, b=B())
199199
f(A(), B()) # E: Argument 2 to "f" has incompatible type "B"; expected "A"
200-
f(A(), b=A()) # E: Argument 2 to "f" has incompatible type "A"; expected "B"
201-
f(*a, b=A()) # E: Argument 2 to "f" has incompatible type "A"; expected "B"
200+
f(A(), b=A()) # E: Argument 2 to "f" has incompatible type "A"; expected "Optional[B]"
201+
f(*a, b=A()) # E: Argument 2 to "f" has incompatible type "A"; expected "Optional[B]"
202202
class A: pass
203203
class B: pass
204204
[builtins fixtures/list.pyi]

test-data/unit/check-varargs.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ a = None # type: A
8686
b = None # type: B
8787
c = None # type: C
8888

89-
f(a) # E: Argument 1 to "f" has incompatible type "A"; expected "C"
89+
f(a) # E: Argument 1 to "f" has incompatible type "A"; expected "Optional[C]"
9090
f(c, c) # E: Argument 2 to "f" has incompatible type "C"; expected "A"
9191
f(c, a, b, c) # E: Argument 4 to "f" has incompatible type "C"; expected "A"
9292
f()
@@ -377,9 +377,10 @@ class B: pass
377377
[builtins fixtures/list.pyi]
378378
[out]
379379
main:3: error: Too few arguments for "f"
380+
main:4: error: Argument 2 to "f" has incompatible type *List[A]; expected "Optional[B]"
380381
main:4: error: Argument 2 to "f" has incompatible type *List[A]; expected "B"
381382
main:5: error: Argument 3 to "f" has incompatible type *List[A]; expected "B"
382-
main:6: error: Argument 1 to "f" has incompatible type *"Tuple[A, A, B]"; expected "B"
383+
main:6: error: Argument 1 to "f" has incompatible type *"Tuple[A, A, B]"; expected "Optional[B]"
383384

384385
[case testVarArgsAfterKeywordArgInCall1-skip]
385386
# see: mypy issue #2729

0 commit comments

Comments
 (0)