File: check-lowercase.test

package info (click to toggle)
mypy 1.19.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 22,464 kB
  • sloc: python: 114,757; ansic: 13,343; cpp: 11,380; makefile: 254; sh: 31
file content (35 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[case testTupleLowercase]
x = (3,)
x = 3 # E: Incompatible types in assignment (expression has type "int", variable has type "tuple[int]")
[builtins fixtures/tuple.pyi]

[case testListLowercase]
x = [3]
x = 3  # E: Incompatible types in assignment (expression has type "int", variable has type "list[int]")

[case testDictLowercase]
x = {"key": "value"}
x = 3  # E: Incompatible types in assignment (expression has type "int", variable has type "dict[str, str]")

[case testSetLowercase]
x = {3}
x = 3  # E: Incompatible types in assignment (expression has type "int", variable has type "set[int]")
[builtins fixtures/set.pyi]

[case testTypeLowercase]
x: type[type]
y: int

y = x  # E: Incompatible types in assignment (expression has type "type[type]", variable has type "int")

[case testLowercaseTypeAnnotationHint]
x = []  # E: Need type annotation for "x" (hint: "x: list[<type>] = ...")
y = {}  # E: Need type annotation for "y" (hint: "y: dict[<type>, <type>] = ...")
z = set()  # E: Need type annotation for "z" (hint: "z: set[<type>] = ...")
[builtins fixtures/primitives.pyi]

[case testLowercaseRevealTypeType]
def f(t: type[int]) -> None:
    reveal_type(t)  # N: Revealed type is "type[builtins.int]"
reveal_type(f)  # N: Revealed type is "def (t: type[builtins.int])"
[builtins fixtures/primitives.pyi]