Skip to content

Commit 2d53523

Browse files
committed
Update all other test cases
1 parent 832119f commit 2d53523

File tree

78 files changed

+1605
-1605
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1605
-1605
lines changed

test-data/unit/check-abstract.test

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ def f(cls: Type[A]) -> A:
191191
def g() -> A:
192192
return A() # E: Cannot instantiate abstract class "A" with abstract attribute "m"
193193

194-
f(A) # E: Only concrete class can be given where "Type[A]" is expected
195-
f(B) # E: Only concrete class can be given where "Type[A]" is expected
194+
f(A) # E: Only concrete class can be given where "type[A]" is expected
195+
f(B) # E: Only concrete class can be given where "type[A]" is expected
196196
f(C) # OK
197197
x: Type[B]
198198
f(x) # OK
@@ -207,7 +207,7 @@ class Class:
207207
def method(self) -> None:
208208
pass
209209

210-
my_dict_init: Dict[int, Type[Class]] = {0: Class} # E: Only concrete class can be given where "Tuple[int, Type[Class]]" is expected
210+
my_dict_init: Dict[int, Type[Class]] = {0: Class} # E: Only concrete class can be given where "tuple[int, type[Class]]" is expected
211211

212212
class Child(Class):
213213
def method(self) -> None: ...
@@ -235,7 +235,7 @@ Alias = A
235235
GoodAlias = C
236236
Alias() # E: Cannot instantiate abstract class "A" with abstract attribute "m"
237237
GoodAlias()
238-
f(Alias) # E: Only concrete class can be given where "Type[A]" is expected
238+
f(Alias) # E: Only concrete class can be given where "type[A]" is expected
239239
f(GoodAlias)
240240
[out]
241241

@@ -255,18 +255,18 @@ class C(B):
255255
var: Type[A]
256256
var()
257257
if int():
258-
var = A # E: Can only assign concrete classes to a variable of type "Type[A]"
258+
var = A # E: Can only assign concrete classes to a variable of type "type[A]"
259259
if int():
260-
var = B # E: Can only assign concrete classes to a variable of type "Type[A]"
260+
var = B # E: Can only assign concrete classes to a variable of type "type[A]"
261261
if int():
262262
var = C # OK
263263

264264
var_old = None # type: Type[A] # Old syntax for variable annotations
265265
var_old()
266266
if int():
267-
var_old = A # E: Can only assign concrete classes to a variable of type "Type[A]"
267+
var_old = A # E: Can only assign concrete classes to a variable of type "type[A]"
268268
if int():
269-
var_old = B # E: Can only assign concrete classes to a variable of type "Type[A]"
269+
var_old = B # E: Can only assign concrete classes to a variable of type "type[A]"
270270
if int():
271271
var_old = C # OK
272272

@@ -277,7 +277,7 @@ class D(A):
277277
def __new__(cls) -> "D": ...
278278
def __new__(cls, a=None) -> "D": ...
279279
if int():
280-
var = D # E: Can only assign concrete classes to a variable of type "Type[A]"
280+
var = D # E: Can only assign concrete classes to a variable of type "type[A]"
281281
[out]
282282

283283
[case testInstantiationAbstractsInTypeForClassMethods]

test-data/unit/check-annotated.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ from typing_extensions import Annotated
105105
T = TypeVar('T')
106106
Alias = Annotated[Tuple[T, T], ...]
107107
x: Alias[int]
108-
reveal_type(x) # N: Revealed type is "Tuple[builtins.int, builtins.int]"
108+
reveal_type(x) # N: Revealed type is "tuple[builtins.int, builtins.int]"
109109
[builtins fixtures/tuple.pyi]
110110

111111
[case testAnnotatedAliasGenericUnion]

test-data/unit/check-async-await.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ async def f() -> None:
163163
[builtins fixtures/async_await.pyi]
164164
[typing fixtures/typing-async.pyi]
165165
[out]
166-
main:4: error: "List[int]" has no attribute "__aiter__" (not async iterable)
166+
main:4: error: "list[int]" has no attribute "__aiter__" (not async iterable)
167167

168168
[case testAsyncForErrorNote]
169169

@@ -502,7 +502,7 @@ async def gen() -> AsyncGenerator[int, str]:
502502

503503
async def h() -> None:
504504
g = gen()
505-
await g.asend(()) # E: Argument 1 to "asend" of "AsyncGenerator" has incompatible type "Tuple[()]"; expected "str"
505+
await g.asend(()) # E: Argument 1 to "asend" of "AsyncGenerator" has incompatible type "tuple[()]"; expected "str"
506506
reveal_type(await g.asend('hello')) # N: Revealed type is "builtins.int"
507507

508508
[builtins fixtures/dict.pyi]
@@ -913,9 +913,9 @@ async def test(x: Sub[D], tx: Type[Sub[D]]) -> None:
913913
unknown2: Awaitable[Any]
914914
d: C = unknown2 # E: Incompatible types in assignment (expression has type "Awaitable[Any]", variable has type "C")
915915

916-
# The notes are not show for Type[...] (because awaiting them will not work)
917-
tx.x # E: "Type[Sub[D]]" has no attribute "x"
918-
a2: C = tx # E: Incompatible types in assignment (expression has type "Type[Sub[D]]", variable has type "C")
916+
# The notes are not show for type[...] (because awaiting them will not work)
917+
tx.x # E: "type[Sub[D]]" has no attribute "x"
918+
a2: C = tx # E: Incompatible types in assignment (expression has type "type[Sub[D]]", variable has type "C")
919919

920920
class F:
921921
def __await__(self: T) -> Generator[Any, Any, T]: ...

test-data/unit/check-basic.test

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ reveal_type(b) # N: Revealed type is "Literal[False]"
378378
from typing import List
379379
x: List[int]
380380
y: List[float]
381-
y = x # E: Incompatible types in assignment (expression has type "List[int]", variable has type "List[float]") \
381+
y = x # E: Incompatible types in assignment (expression has type "list[int]", variable has type "list[float]") \
382382
# N: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance \
383383
# N: Consider using "Sequence" instead, which is covariant
384384
[builtins fixtures/list.pyi]
@@ -387,7 +387,7 @@ y = x # E: Incompatible types in assignment (expression has type "List[int]", va
387387
from typing import Dict
388388
x: Dict[str, int]
389389
y: Dict[str, float]
390-
y = x # E: Incompatible types in assignment (expression has type "Dict[str, int]", variable has type "Dict[str, float]") \
390+
y = x # E: Incompatible types in assignment (expression has type "dict[str, int]", variable has type "dict[str, float]") \
391391
# N: "dict" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance \
392392
# N: Consider using "Mapping" instead, which is covariant in the value type
393393
[builtins fixtures/dict.pyi]
@@ -420,7 +420,7 @@ def foo() -> Optional[A]:
420420

421421
def bar() -> List[A]:
422422
l = [a.A()]
423-
return l # E: Incompatible return value type (got "List[a.A]", expected "List[b.A]")
423+
return l # E: Incompatible return value type (got "list[a.A]", expected "list[b.A]")
424424

425425
def baz() -> Union[A, int]:
426426
b = True
@@ -431,37 +431,37 @@ def spam() -> Optional[A]:
431431

432432
def eggs() -> Sequence[A]:
433433
x = [a.A()]
434-
return x # E: Incompatible return value type (got "List[a.A]", expected "Sequence[b.A]")
434+
return x # E: Incompatible return value type (got "list[a.A]", expected "Sequence[b.A]")
435435

436436
def eggs2() -> Sequence[N]:
437437
x = [a.N(0)]
438-
return x # E: Incompatible return value type (got "List[a.N]", expected "Sequence[b.N]")
438+
return x # E: Incompatible return value type (got "list[a.N]", expected "Sequence[b.N]")
439439

440440
def asdf1() -> Sequence[Tuple[a.A, A]]:
441441
x = [(a.A(), a.A())]
442-
return x # E: Incompatible return value type (got "List[Tuple[a.A, a.A]]", expected "Sequence[Tuple[a.A, b.A]]")
442+
return x # E: Incompatible return value type (got "list[tuple[a.A, a.A]]", expected "Sequence[tuple[a.A, b.A]]")
443443

444444
def asdf2() -> Sequence[Tuple[A, a.A]]:
445445
x = [(a.A(), a.A())]
446-
return x # E: Incompatible return value type (got "List[Tuple[a.A, a.A]]", expected "Sequence[Tuple[b.A, a.A]]")
446+
return x # E: Incompatible return value type (got "list[tuple[a.A, a.A]]", expected "Sequence[tuple[b.A, a.A]]")
447447

448448
def arg() -> Tuple[A, A]:
449-
return A() # E: Incompatible return value type (got "A", expected "Tuple[A, A]")
449+
return A() # E: Incompatible return value type (got "A", expected "tuple[A, A]")
450450

451451
def types() -> Sequence[Type[A]]:
452452
x = [a.A]
453-
return x # E: Incompatible return value type (got "List[Type[a.A]]", expected "Sequence[Type[b.A]]")
453+
return x # E: Incompatible return value type (got "list[type[a.A]]", expected "Sequence[type[b.A]]")
454454

455455
def literal() -> Sequence[Literal[B.b]]:
456456
x = [a.B.b] # type: List[Literal[a.B.b]]
457-
return x # E: Incompatible return value type (got "List[Literal[a.B.b]]", expected "Sequence[Literal[b.B.b]]")
457+
return x # E: Incompatible return value type (got "list[Literal[a.B.b]]", expected "Sequence[Literal[b.B.b]]")
458458

459459
def typeddict() -> Sequence[D]:
460460
x = [{'x': 0}] # type: List[a.D]
461-
return x # E: Incompatible return value type (got "List[a.D]", expected "Sequence[b.D]")
461+
return x # E: Incompatible return value type (got "list[a.D]", expected "Sequence[b.D]")
462462

463463
a = (a.A(), A())
464-
a.x # E: "Tuple[a.A, b.A]" has no attribute "x"
464+
a.x # E: "tuple[a.A, b.A]" has no attribute "x"
465465
[builtins fixtures/dict.pyi]
466466
[typing fixtures/typing-full.pyi]
467467

test-data/unit/check-class-namedtuple.test

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ t: Tuple[int, str]
187187
if int():
188188
b = a # E: Incompatible types in assignment (expression has type "A", variable has type "B")
189189
if int():
190-
a = t # E: Incompatible types in assignment (expression has type "Tuple[int, str]", variable has type "A")
190+
a = t # E: Incompatible types in assignment (expression has type "tuple[int, str]", variable has type "A")
191191
if int():
192-
b = t # E: Incompatible types in assignment (expression has type "Tuple[int, str]", variable has type "B")
192+
b = t # E: Incompatible types in assignment (expression has type "tuple[int, str]", variable has type "B")
193193
if int():
194194
t = a
195195
if int():
@@ -212,7 +212,7 @@ a = l[0]
212212
(i,) = l[0]
213213
i, i = l[0] # E: Need more than 1 value to unpack (2 expected)
214214
l = [A(1)]
215-
a = (1,) # E: Incompatible types in assignment (expression has type "Tuple[int]", \
215+
a = (1,) # E: Incompatible types in assignment (expression has type "tuple[int]", \
216216
variable has type "A")
217217
[builtins fixtures/list.pyi]
218218

@@ -223,7 +223,7 @@ class MyNamedTuple(NamedTuple):
223223
a: int
224224
b: str
225225

226-
MyNamedTuple.x # E: "Type[MyNamedTuple]" has no attribute "x"
226+
MyNamedTuple.x # E: "type[MyNamedTuple]" has no attribute "x"
227227
[builtins fixtures/tuple.pyi]
228228

229229
[case testNewNamedTupleEmptyItems]
@@ -281,7 +281,7 @@ class X(NamedTuple):
281281
y: str
282282

283283
x: X
284-
reveal_type(x._replace()) # N: Revealed type is "Tuple[builtins.int, builtins.str, fallback=__main__.X]"
284+
reveal_type(x._replace()) # N: Revealed type is "tuple[builtins.int, builtins.str, fallback=__main__.X]"
285285
x._replace(x=5)
286286
x._replace(y=5) # E: Argument "y" to "_replace" of "X" has incompatible type "int"; expected "str"
287287
[builtins fixtures/tuple.pyi]
@@ -293,7 +293,7 @@ class X(NamedTuple):
293293
x: int
294294
y: str
295295

296-
reveal_type(X._fields) # N: Revealed type is "Tuple[builtins.str, builtins.str]"
296+
reveal_type(X._fields) # N: Revealed type is "tuple[builtins.str, builtins.str]"
297297
reveal_type(X._field_types) # N: Revealed type is "builtins.dict[builtins.str, Any]"
298298
reveal_type(X._field_defaults) # N: Revealed type is "builtins.dict[builtins.str, Any]"
299299

@@ -324,7 +324,7 @@ class Y(NamedTuple):
324324
x: int
325325
y: str
326326

327-
reveal_type([X(3, 'b'), Y(1, 'a')]) # N: Revealed type is "builtins.list[Tuple[builtins.int, builtins.str]]"
327+
reveal_type([X(3, 'b'), Y(1, 'a')]) # N: Revealed type is "builtins.list[tuple[builtins.int, builtins.str]]"
328328

329329
[builtins fixtures/list.pyi]
330330

@@ -335,8 +335,8 @@ class X(NamedTuple):
335335
x: int
336336
y: str
337337

338-
reveal_type([(3, 'b'), X(1, 'a')]) # N: Revealed type is "builtins.list[Tuple[builtins.int, builtins.str]]"
339-
reveal_type([X(1, 'a'), (3, 'b')]) # N: Revealed type is "builtins.list[Tuple[builtins.int, builtins.str]]"
338+
reveal_type([(3, 'b'), X(1, 'a')]) # N: Revealed type is "builtins.list[tuple[builtins.int, builtins.str]]"
339+
reveal_type([X(1, 'a'), (3, 'b')]) # N: Revealed type is "builtins.list[tuple[builtins.int, builtins.str]]"
340340

341341
[builtins fixtures/list.pyi]
342342

@@ -386,8 +386,8 @@ class X(NamedTuple):
386386
x: int
387387
y: int = 2
388388

389-
reveal_type(X(1)) # N: Revealed type is "Tuple[builtins.int, builtins.int, fallback=__main__.X]"
390-
reveal_type(X(1, 2)) # N: Revealed type is "Tuple[builtins.int, builtins.int, fallback=__main__.X]"
389+
reveal_type(X(1)) # N: Revealed type is "tuple[builtins.int, builtins.int, fallback=__main__.X]"
390+
reveal_type(X(1, 2)) # N: Revealed type is "tuple[builtins.int, builtins.int, fallback=__main__.X]"
391391

392392
X(1, 'a') # E: Argument 2 to "X" has incompatible type "str"; expected "int"
393393
X(1, z=3) # E: Unexpected keyword argument "z" for "X"
@@ -396,14 +396,14 @@ class HasNone(NamedTuple):
396396
x: int
397397
y: Optional[int] = None
398398

399-
reveal_type(HasNone(1)) # N: Revealed type is "Tuple[builtins.int, Union[builtins.int, None], fallback=__main__.HasNone]"
399+
reveal_type(HasNone(1)) # N: Revealed type is "tuple[builtins.int, Union[builtins.int, None], fallback=__main__.HasNone]"
400400

401401
class Parameterized(NamedTuple):
402402
x: int
403403
y: List[int] = [1] + [2]
404404
z: List[int] = []
405405

406-
reveal_type(Parameterized(1)) # N: Revealed type is "Tuple[builtins.int, builtins.list[builtins.int], builtins.list[builtins.int], fallback=__main__.Parameterized]"
406+
reveal_type(Parameterized(1)) # N: Revealed type is "tuple[builtins.int, builtins.list[builtins.int], builtins.list[builtins.int], fallback=__main__.Parameterized]"
407407
Parameterized(1, ['not an int']) # E: List item 0 has incompatible type "str"; expected "int"
408408

409409
class Default:
@@ -412,8 +412,8 @@ class Default:
412412
class UserDefined(NamedTuple):
413413
x: Default = Default()
414414

415-
reveal_type(UserDefined()) # N: Revealed type is "Tuple[__main__.Default, fallback=__main__.UserDefined]"
416-
reveal_type(UserDefined(Default())) # N: Revealed type is "Tuple[__main__.Default, fallback=__main__.UserDefined]"
415+
reveal_type(UserDefined()) # N: Revealed type is "tuple[__main__.Default, fallback=__main__.UserDefined]"
416+
reveal_type(UserDefined(Default())) # N: Revealed type is "tuple[__main__.Default, fallback=__main__.UserDefined]"
417417
UserDefined(1) # E: Argument 1 to "UserDefined" has incompatible type "int"; expected "Default"
418418

419419
[builtins fixtures/list.pyi]
@@ -425,7 +425,7 @@ class HasNone(NamedTuple):
425425
x: int
426426
y: Optional[int] = None
427427

428-
reveal_type(HasNone(1)) # N: Revealed type is "Tuple[builtins.int, Union[builtins.int, None], fallback=__main__.HasNone]"
428+
reveal_type(HasNone(1)) # N: Revealed type is "tuple[builtins.int, Union[builtins.int, None], fallback=__main__.HasNone]"
429429
HasNone(None) # E: Argument 1 to "HasNone" has incompatible type "None"; expected "int"
430430
HasNone(1, y=None)
431431
HasNone(1, y=2)
@@ -463,7 +463,7 @@ class Y(X):
463463
self.y
464464
return self.x
465465

466-
reveal_type(Y('a')) # N: Revealed type is "Tuple[builtins.str, builtins.int, fallback=__main__.Y]"
466+
reveal_type(Y('a')) # N: Revealed type is "tuple[builtins.str, builtins.int, fallback=__main__.Y]"
467467
Y(y=1, x='1').method()
468468

469469
class CallsBaseInit(X):
@@ -511,7 +511,7 @@ class Overloader(NamedTuple):
511511

512512
reveal_type(Overloader(1).method('string')) # N: Revealed type is "builtins.str"
513513
reveal_type(Overloader(1).method(1)) # N: Revealed type is "builtins.int"
514-
Overloader(1).method(('tuple',)) # E: No overload variant of "method" of "Overloader" matches argument type "Tuple[str]" \
514+
Overloader(1).method(('tuple',)) # E: No overload variant of "method" of "Overloader" matches argument type "tuple[str]" \
515515
# N: Possible overload variants: \
516516
# N: def method(self, y: str) -> str \
517517
# N: def method(self, y: int) -> int
@@ -528,7 +528,7 @@ class Base(NamedTuple):
528528
reveal_type(self) # N: Revealed type is "T`-1"
529529
return self
530530
def good_override(self) -> int:
531-
reveal_type(self) # N: Revealed type is "Tuple[builtins.int, fallback=__main__.Base]"
531+
reveal_type(self) # N: Revealed type is "tuple[builtins.int, fallback=__main__.Base]"
532532
reveal_type(self[0]) # N: Revealed type is "builtins.int"
533533
self[0] = 3 # E: Unsupported target for indexed assignment ("Base")
534534
reveal_type(self.x) # N: Revealed type is "builtins.int"
@@ -538,14 +538,14 @@ class Base(NamedTuple):
538538
# E: No overload variant of "__getitem__" of "tuple" matches argument type "TypeVar" \
539539
# N: Possible overload variants: \
540540
# N: def __getitem__(self, int, /) -> int \
541-
# N: def __getitem__(self, slice, /) -> Tuple[int, ...]
541+
# N: def __getitem__(self, slice, /) -> tuple[int, ...]
542542
return self.x
543543
def bad_override(self) -> int:
544544
return self.x
545545

546546
class Child(Base):
547547
def new_method(self) -> int:
548-
reveal_type(self) # N: Revealed type is "Tuple[builtins.int, fallback=__main__.Child]"
548+
reveal_type(self) # N: Revealed type is "tuple[builtins.int, fallback=__main__.Child]"
549549
reveal_type(self[0]) # N: Revealed type is "builtins.int"
550550
self[0] = 3 # E: Unsupported target for indexed assignment ("Child")
551551
reveal_type(self.x) # N: Revealed type is "builtins.int"
@@ -560,8 +560,8 @@ class Child(Base):
560560
def takes_base(base: Base) -> int:
561561
return base.x
562562

563-
reveal_type(Base(1).copy()) # N: Revealed type is "Tuple[builtins.int, fallback=__main__.Base]"
564-
reveal_type(Child(1).copy()) # N: Revealed type is "Tuple[builtins.int, fallback=__main__.Child]"
563+
reveal_type(Base(1).copy()) # N: Revealed type is "tuple[builtins.int, fallback=__main__.Base]"
564+
reveal_type(Child(1).copy()) # N: Revealed type is "tuple[builtins.int, fallback=__main__.Child]"
565565
reveal_type(Base(1).good_override()) # N: Revealed type is "builtins.int"
566566
reveal_type(Child(1).good_override()) # N: Revealed type is "builtins.int"
567567
reveal_type(Base(1).bad_override()) # N: Revealed type is "builtins.int"
@@ -635,8 +635,8 @@ class HasClassMethod(NamedTuple):
635635

636636
@classmethod
637637
def new(cls, f: str) -> 'HasClassMethod':
638-
reveal_type(cls) # N: Revealed type is "Type[Tuple[builtins.str, fallback=__main__.HasClassMethod]]"
639-
reveal_type(HasClassMethod) # N: Revealed type is "def (x: builtins.str) -> Tuple[builtins.str, fallback=__main__.HasClassMethod]"
638+
reveal_type(cls) # N: Revealed type is "type[tuple[builtins.str, fallback=__main__.HasClassMethod]]"
639+
reveal_type(HasClassMethod) # N: Revealed type is "def (x: builtins.str) -> tuple[builtins.str, fallback=__main__.HasClassMethod]"
640640
return cls(x=f)
641641

642642
[builtins fixtures/classmethod.pyi]
@@ -661,7 +661,7 @@ class HasStaticMethod(NamedTuple):
661661

662662
@property
663663
def size(self) -> int:
664-
reveal_type(self) # N: Revealed type is "Tuple[builtins.str, fallback=__main__.HasStaticMethod]"
664+
reveal_type(self) # N: Revealed type is "tuple[builtins.str, fallback=__main__.HasStaticMethod]"
665665
return 4
666666

667667
[builtins fixtures/property.pyi]

0 commit comments

Comments
 (0)