File: fine-grained-python312.test

package info (click to toggle)
mypy 1.19.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,412 kB
  • sloc: python: 114,754; ansic: 13,343; cpp: 11,380; makefile: 257; sh: 28
file content (117 lines) | stat: -rw-r--r-- 2,097 bytes parent folder | download
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
[case testPEP695TypeAliasDep]
import m
def g() -> m.C:
    return m.f()
[file m.py]
type C = int

def f() -> int:
    pass
[file m.py.2]
type C = str

def f() -> int:
    pass
[out]
==
main:3: error: Incompatible return value type (got "int", expected "str")

[case testPEP695ChangeOldStyleToNewStyleTypeAlias]
from m import A
A()

[file m.py]
A = int

[file m.py.2]
type A = int
[typing fixtures/typing-full.pyi]
[builtins fixtures/tuple.pyi]
[out]
==
main:2: error: "TypeAliasType" not callable

[case testPEP695VarianceChangesDueToDependency]
from a import C

x: C[object] = C[int]()

[file a.py]
from b import A

class C[T]:
    def f(self) -> A[T]: ...

[file b.py]
class A[T]:
    def f(self) -> T: ...

[file b.py.2]
class A[T]:
    def f(self) -> list[T]: ...

[out]
==
main:3: error: Incompatible types in assignment (expression has type "C[int]", variable has type "C[object]")

[case testPEP695TypeAliasChangesDueToDependency]
from a import A
x: A
x = 0
x = ''

[file a.py]
from b import B
type A = B[int, str]

[file b.py]
from typing import Union as B

[file b.py.2]
from builtins import tuple as B

[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]
[out]
==
main:3: error: Incompatible types in assignment (expression has type "int", variable has type "tuple[int, str]")
main:4: error: Incompatible types in assignment (expression has type "str", variable has type "tuple[int, str]")

[case testPEP695NestedGenericClassMethodUpdated]
from a import f

class C:
    class D[T]:
        x: T
        def m(self) -> T:
            f()
            return self.x

[file a.py]
def f() -> None: pass

[file a.py.2]
def f(x: int) -> None: pass
[out]
==
main:7: error: Missing positional argument "x" in call to "f"

[case testPEP695MultipleNestedGenericClassMethodUpdated]
from a import f

class A:
    class C:
        class D[T]:
            x: T
            def m(self) -> T:
                f()
                return self.x

[file a.py]
def f() -> None: pass

[file a.py.2]
def f(x: int) -> None: pass
[out]
==
main:8: error: Missing positional argument "x" in call to "f"