8000 Fix new style union syntax in type aliases (#14008) · python/mypy@39d35cd · GitHub
[go: up one dir, main page]

Skip to content

Commit 39d35cd

Browse files
authored
Fix new style union syntax in type aliases (#14008)
Fix Python 3.10 `|` union syntax in type aliases, when one of the operands is a type alias or a type with an overloaded `__init__`. We can now infer `typing._SpecialForm` for type aliases in a runtime context. Also create a bunch of minimal test-only stubs for stdlib modules to fix some test failures caused by the missing `typing._SpecialForm` in the default test stubs. This is generally what we want in any case, since using typeshed stubs with minimal builtins/typing stubs can result in unpredictable behavior and slow tests. Fixes #12368. Fixes #12005. Fixes #11426.
1 parent d2a3e66 commit 39d35cd

21 files changed

+186
-27
lines changed

mypy/checker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6048,11 +6048,11 @@ def lookup_qualified(self, name: str) -> SymbolTableNode:
60486048
last = parts[-1]
60496049
if last in n.names:
60506050
return n.names[last]
6051-
elif len(parts) == 2 and parts[0] == "builtins":
6052-
fullname = "builtins." + last
6051+
elif len(parts) == 2 and parts[0] in ("builtins", "typing"):
6052+
fullname = ".".join(parts)
60536053
if fullname in SUGGESTED_TEST_FIXTURES:
6054-
suggestion = ", e.g. add '[builtins fixtures/{}]' to your test".format(
6055-
SUGGESTED_TEST_FIXTURES[fullname]
6054+
suggestion = ", e.g. add '[{} fixtures/{}]' to your test".format(
6055+
parts[0], SUGGESTED_TEST_FIXTURES[fullname]
60566056
)
60576057
else:
60586058
suggestion = ""

mypy/checkexpr.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3870,9 +3870,8 @@ class LongName(Generic[T]): ...
38703870
else:
38713871
if alias_definition:
38723872
return AnyType(TypeOfAny.special_form)
3873-
# This type is invalid in most runtime contexts, give it an 'object' type.
3874-
# TODO: Use typing._SpecialForm instead?
3875-
return self.named_type("builtins.object")
3873+
# The _SpecialForm type can be used in some runtime contexts (e.g. it may have __or__).
3874+
return self.named_type("typing._SpecialForm")
38763875

38773876
def apply_type_arguments_to_callable(
38783877
self, tp: Type, args: Sequence[Type], ctx: Context
@@ -4742,7 +4741,7 @@ def has_member(self, typ: Type, member: str) -> bool:
47424741
typ = typ.fallback
47434742
if isinstance(typ, Instance):
47444743
return typ.type.has_readable_member(member)
4745-
if isinstance(typ, CallableType) and typ.is_type_obj():
4744+
if isinstance(typ, FunctionLike) and typ.is_type_obj():
47464745
return typ.fallback.type.has_readable_member(member)
47474746
elif isinstance(typ, AnyType):
47484747
return True

mypy/messages.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
"builtins.isinstance": "isinstancelist.pyi",
133133
"builtins.property": "property.pyi",
134134
"builtins.classmethod": "classmethod.pyi",
135+
"typing._SpecialForm": "typing-medium.pyi",
135136
}
136137

137138

@@ -2253,6 +2254,9 @@ def format_literal_value(typ: LiteralType) -> str:
22532254
if itype.extra_attrs and itype.extra_attrs.mod_name and module_names:
22542255
return f"{base_str} {itype.extra_attrs.mod_name}"
22552256
return base_str
2257+
if itype.type.fullname == "typing._SpecialForm":
2258+
# This is not a real type but used for some typing-related constructs.
2259+
return "<typing special form>"
22562260
if verbosity >= 2 or (fullnames and itype.type.fullname in fullnames):
22572261
base_str = itype.type.fullname
22582262
else:

mypyc/test-data/run-async.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ async def g() -> int:
1313
async def f() -> int:
1414
return await g()
1515

16+
[file asyncio/__init__.pyi]
17+
async def sleep(t: float) -> None: ...
18+
1619
[typing fixtures/typing-full.pyi]
1720

1821
[file driver.py]

test-data/unit/check-ctypes.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ a[3] = b"bytes" # E: No overload variant of "__setitem__" of "Array" matches ar
2020
for x in a:
2121
reveal_type(x) # N: Revealed type is "builtins.int"
2222
[builtins fixtures/floatdict.pyi]
23+
[typing fixtures/typing-medium.pyi]
2324

2425
[case testCtypesArrayCustomElementType]
2526
import ctypes
@@ -52,6 +53,7 @@ myu: Union[ctypes.Array[ctypes.c_int], List[str]]
5253
for myi in myu:
5354
reveal_type(myi) # N: Revealed type is "Union[builtins.int, builtins.str]"
5455
[builtins fixtures/floatdict.pyi]
56+
[typing fixtures/typing-medium.pyi]
5557

5658
[case testCtypesArrayUnionElementType]
5759
import ctypes
@@ -76,6 +78,7 @@ mya[3] = b"bytes" # E: No overload variant of "__setitem__" of "Array" matches
7678
for myx in mya:
7779
reveal_type(myx) # N: Revealed type is "Union[__main__.MyCInt, builtins.int]"
7880
[builtins fixtures/floatdict.pyi]
81+
[typing fixtures/typing-medium.pyi]
7982

8083
[case testCtypesCharArrayAttrs]
8184
import ctypes
@@ -84,13 +87,15 @@ ca = (ctypes.c_char * 4)(b'a', b'b', b'c', b'\x00')
8487
reveal_type(ca.value) # N: Revealed type is "builtins.bytes"
8588
reveal_type(ca.raw) # N: Revealed type is "builtins.bytes"
8689
[builtins fixtures/floatdict.pyi]
90+
[typing fixtures/typing-medium.pyi]
8791

8892
[case testCtypesCharPArrayDoesNotCrash]
8993
import ctypes
9094

9195
# The following line used to crash with "Could not find builtin symbol 'NoneType'"
9296
ca = (ctypes.c_char_p * 0)()
9397
[builtins fixtures/floatdict.pyi]
98+
[typing fixtures/typing-medium.pyi]
9499

95100
[case testCtypesWcharArrayAttrs]
96101
import ctypes
@@ -99,6 +104,7 @@ wca = (ctypes.c_wchar * 4)('a', 'b', 'c', '\x00')
99104
reveal_type(wca.value) # N: Revealed type is "builtins.str"
100105
wca.raw # E: Array attribute "raw" is only available with element type "c_char", not "c_wchar"
101106
[builtins fixtures/floatdict.pyi]
107+
[typing fixtures/typing-medium.pyi]
102108

103109
[case testCtypesCharUnionArrayAttrs]
104110
import ctypes
@@ -108,6 +114,7 @@ cua: ctypes.Array[Union[ctypes.c_char, ctypes.c_wchar]]
108114
reveal_type(cua.value) # N: Revealed type is "Union[builtins.bytes, builtins.str]"
109115
cua.raw # E: Array attribute "raw" is only available with element type "c_char", not "Union[c_char, c_wchar]"
110116
[builtins fixtures/floatdict.pyi]
117+
[typing fixtures/typing-medium.pyi]
111118

112119
[case testCtypesAnyUnionArrayAttrs]
113120
import ctypes
@@ -117,6 +124,7 @@ caa: ctypes.Array[Union[ctypes.c_char, Any]]
117124
reveal_type(caa.value) # N: Revealed type is "Union[builtins.bytes, Any]"
118125
reveal_type(caa.raw) # N: Revealed type is "builtins.bytes"
119126
[builtins fixtures/floatdict.pyi]
127+
[typing fixtures/typing-medium.pyi]
120128

121129
[case testCtypesOtherUnionArrayAttrs]
122130
import ctypes
@@ -126,6 +134,7 @@ cua: ctypes.Array[Union[ctypes.c_char, ctypes.c_int]]
126134
cua.value # E: Array attribute "value" is only available with element type "c_char" or "c_wchar", not "Union[c_char, c_int]"
127135
cua.raw # E: Array attribute "raw" is only available with element type "c_char", not "Union[c_char, c_int]"
128136
[builtins fixtures/floatdict.pyi]
137+
[typing fixtures/typing-medium.pyi]
129138

130139
[case testCtypesAnyArrayAttrs]
131140
import ctypes
@@ -134,6 +143,7 @@ aa: ctypes.Array[Any]
134143
reveal_type(aa.value) # N: Revealed type is "Any"
135144
reveal_type(aa.raw) # N: Revealed type is "builtins.bytes"
136145
[builtins fixtures/floatdict.pyi]
146+
[typing fixtures/typing-medium.pyi]
137147

138148
[case testCtypesOtherArrayAttrs]
139149
import ctypes
@@ -142,6 +152,7 @@ oa = (ctypes.c_int * 4)(1, 2, 3, 4)
142152
oa.value # E: Array attribute "value" is only available with element type "c_char" or "c_wchar", not "c_int"
143153
oa.raw # E: Array attribute "raw" is only available with element type "c_char", not "c_int"
144154
[builtins fixtures/floatdict.pyi]
155+
[typing fixtures/typing-medium.pyi]
145156

146157
[case testCtypesArrayConstructorStarargs]
147158
import ctypes
@@ -154,6 +165,7 @@ reveal_type(intarr4(*int_values)) # N: Revealed type is "ctypes.Array[ctypes.c_
154165
reveal_type(intarr4(*c_int_values)) # N: Revealed type is "ctypes.Array[ctypes.c_int]"
155166
reveal_type(intarr6(1, ctypes.c_int(2), *int_values)) # N: Revealed type is "ctypes.Array[ctypes.c_int]"
156167
reveal_type(intarr6(1, ctypes.c_int(2), *c_int_values)) # N: Revealed type is "ctypes.Array[ctypes.c_int]"
168+
[typing fixtures/typing-medium.pyi]
157169

158170
float_values = [1.0, 2.0, 3.0, 4.0]
159171
intarr4(*float_values) # E: Array constructor argument 1 of type "List[float]" is not convertible to the array element type "Iterable[c_int]"
@@ -167,3 +179,4 @@ x = {"a": 1, "b": 2}
167179
intarr4(**x)
168180

169181
[builtins fixtures/floatdict.pyi]
182+
[typing fixtures/typing-medium.pyi]

test-data/unit/check-dataclasses.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,9 @@ class Two:
633633

634634
c = Two()
635635
x = c.S
636-
reveal_type(x) # N: Revealed type is "builtins.object"
636+
reveal_type(x) # N: Revealed type is "typing._SpecialForm"
637637
[builtins fixtures/dataclasses.pyi]
638+
[typing fixtures/typing-medium.pyi]
638639

639640
[case testDataclassOrdering]
640641
# flags: --python-version 3.7

test-data/unit/check-generics.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,20 +1049,20 @@ CA = Callable[[T], int]
10491049
TA = Tuple[T, int]
10501050
UA = Union[T, int]
10511051

1052-
cs = CA + 1 # E: Unsupported left operand type for + ("object")
1052+
cs = CA + 1 # E: Unsupported left operand type for + ("<typing special form>")
10531053
reveal_type(cs) # N: Revealed type is "Any"
10541054

1055-
ts = TA() # E: "object" not callable
1055+
ts = TA() # E: "<typing special form>" not callable
10561056
reveal_type(ts) # N: Revealed type is "Any"
10571057

1058-
us = UA.x # E: "object" has no attribute "x"
1058+
us = UA.x # E: "<typing special form>" has no attribute "x"
10591059
reveal_type(us) # N: Revealed type is "Any"
10601060

10611061
xx = CA[str] + 1 # E: Type application is only supported for generic classes
10621062
yy = TA[str]() # E: Type application is only supported for generic classes
10631063
zz = UA[str].x # E: Type application is only supported for generic classes
10641064
[builtins fixtures/tuple.pyi]
1065-
1065+
[typing fixtures/typing-medium.pyi]
10661066
[out]
10671067

10681068
[case testGenericTypeAliasesTypeVarBinding]

test-data/unit/check-literal.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,16 +1484,17 @@ Alias = Literal[3]
14841484

14851485
isinstance(3, Literal[3]) # E: Cannot use isinstance() with Literal type
14861486
isinstance(3, Alias) # E: Cannot use isinstance() with Literal type \
1487-
# E: Argument 2 to "isinstance" has incompatible type "object"; expected "Union[type, Tuple[Any, ...]]"
1487+
# E: Argument 2 to "isinstance" has incompatible type "<typing special form>"; expected "Union[type, Tuple[Any, ...]]"
14881488
isinstance(3, Renamed[3]) # E: Cannot use isinstance() with Literal type
14891489
isinstance(3, indirect.Literal[3]) # E: Cannot use isinstance() with Literal type
14901490

14911491
issubclass(int, Literal[3]) # E: Cannot use issubclass() with Literal type
14921492
issubclass(int, Alias) # E: Cannot use issubclass() with Literal type \
1493-
# E: Argument 2 to "issubclass" has incompatible type "object"; expected "Union[type, Tuple[Any, ...]]"
1493+
# E: Argument 2 to "issubclass" has incompatible type "<typing special form>"; expected "Union[type, Tuple[Any, ...]]"
14941494
issubclass(int, Renamed[3]) # E: Cannot use issubclass() with Literal type
14951495
issubclass(int, indirect.Literal[3]) # E: Cannot use issubclass() with Literal type
14961496
[builtins fixtures/isinstancelist.pyi]
1497+
[typing fixtures/typing-medium.pyi]
14971498
[out]
14981499

14991500
[case testLiteralErrorsWhenSubclassed]

test-data/unit/check-python310.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,3 +1788,19 @@ def f6(a: object) -> None:
17881788
case _ if y is not None: # E: Name "y" may be undefined
17891789
pass
17901790
[builtins fixtures/tuple.pyi]
1791+
1792+
[case testTypeAliasWithNewUnionSyntaxAndNoneLeftOperand]
1793+
from typing import overload
1794+
class C:
1795+
@overload
1796+
def __init__(self) -> None: pass
1797+
@overload
1798+
def __init__(self, x: int) -> None: pass
1799+
def __init__(self, x=0):
1800+
pass
1801+
1802+
class D: pass
1803+
1804+
X = None | C
1805+
Y = None | D
1806+
[builtins fixtures/type.pyi]

test-data/unit/check-type-aliases.test

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -821,28 +821,28 @@ c = Child()
821821

822822
reveal_type(NormalImplicit) # N: Revealed type is "def () -> __main__.Foo"
823823
reveal_type(NormalExplicit) # N: Revealed type is "def () -> __main__.Foo"
824-
reveal_type(SpecialImplicit) # N: Revealed type is "builtins.object"
825-
reveal_type(SpecialExplicit) # N: Revealed type is "builtins.object"
824+
reveal_type(SpecialImplicit) # N: Revealed type is "typing._SpecialForm"
825+
reveal_type(SpecialExplicit) # N: Revealed type is "typing._SpecialForm"
826826

827827
reveal_type(Parent.NormalImplicit) # N: Revealed type is "def () -> __main__.Foo"
828828
reveal_type(Parent.NormalExplicit) # N: Revealed type is "def () -> __main__.Foo"
829-
reveal_type(Parent.SpecialImplicit) # N: Revealed type is "builtins.object"
830-
reveal_type(Parent.SpecialExplicit) # N: Revealed type is "builtins.object"
829+
reveal_type(Parent.SpecialImplicit) # N: Revealed type is "typing._SpecialForm"
830+
reveal_type(Parent.SpecialExplicit) # N: Revealed type is "typing._SpecialForm"
831831

832832
reveal_type(Child.NormalImplicit) # N: Revealed type is "def () -> __main__.Foo"
833833
reveal_type(Child.NormalExplicit) # N: Revealed type is "def () -> __main__.Foo"
834-
reveal_type(Child.SpecialImplicit) # N: Revealed type is "builtins.object"
835-
reveal_type(Child.SpecialExplicit) # N: Revealed type is "builtins.object"
834+
reveal_type(Child.SpecialImplicit) # N: Revealed type is "typing._SpecialForm"
835+
reveal_type(Child.SpecialExplicit) # N: Revealed type is "typing._SpecialForm"
836836

837837
reveal_type(p.NormalImplicit) # N: Revealed type is "def () -> __main__.Foo"
838838
reveal_type(p.NormalExplicit) # N: Revealed type is "def () -> __main__.Foo"
839-
reveal_type(p.SpecialImplicit) # N: Revealed type is "builtins.object"
840-
reveal_type(p.SpecialExplicit) # N: Revealed type is "builtins.object"
839+
reveal_type(p.SpecialImplicit) # N: Revealed type is "typing._SpecialForm"
840+
reveal_type(p.SpecialExplicit) # N: Revealed type is "typing._SpecialForm"
841841

842842
reveal_type(c.NormalImplicit) # N: Revealed type is "def () -> __main__.Foo"
843843
reveal_type(p.NormalExplicit) # N: Revealed type is "def () -> __main__.Foo"
844-
reveal_type(c.SpecialImplicit) # N: Revealed type is "builtins.object"
845-
reveal_type(c.SpecialExplicit) # N: Revealed type is "builtins.object"
844+
reveal_type(c.SpecialImplicit) # N: Revealed type is "typing._SpecialForm"
845+
reveal_type(c.SpecialExplicit) # N: Revealed type is "typing._SpecialForm"
846846

847847
# Use type aliases in a type alias context in a plausible way
848848

@@ -895,6 +895,7 @@ reveal_type(weird_child_2) # N: Revealed type is "def () -> Any"
895895
reveal_type(weird_child_3) # N: Revealed type is "def () -> Any"
896896
reveal_type(weird_child_4) # N: Revealed type is "def () -> Any"
897897
[builtins fixtures/tuple.pyi]
898+
[typing fixtures/typing-medium.pyi]
898899

899900
[case testMalformedTypeAliasRuntimeReassignments]
900901
from typing import Union
@@ -927,8 +928,8 @@ SpecialExplicit = 4 # E: Cannot assign multiple types to name "SpecialExplicit"
927928

928929
Parent.NormalImplicit = 4 # E: Incompatible types in assignment (expression has type "int", variable has type "Type[Foo]")
929930
Parent.NormalExplicit = 4 # E: Incompatible types in assignment (expression has type "int", variable has type "Type[Foo]")
930-
Parent.SpecialImplicit = 4
931-
Parent.SpecialExplicit = 4
931+
Parent.SpecialImplicit = 4 # E: Incompatible types in assignment (expression has type "int", variable has type "<typing special form>")
932+
Parent.SpecialExplicit = 4 # E: Incompatible types in assignment (expression has type "int", variable has type "<typing special form>")
932933

933934
Child.NormalImplicit = 4 # E: Incompatible types in assignment (expression has type "int", variable has type "Type[Foo]")
934935
Child.NormalExplicit = 4 # E: Incompatible types in assignment (expression has type "int", variable has type "Type[Foo]")
@@ -945,3 +946,4 @@ c.NormalExplicit = 4 # E: Incompatible types in assignment (expression has type
945946
c.SpecialImplicit = 4
946947
c.SpecialExplicit = 4
947948
[builtins fixtures/tuple.pyi]
949+
[typing fixtures/typing-medium.pyi]

test-data/unit/fixtures/args.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class list(Sequence[T], Generic[T]): pass
2626

2727
class int:
2828
def __eq__(self, o: object) -> bool: pass
29+
class float: pass
2930
class str: pass
3031
class bytes: pass
3132
class bool: pass

test-data/unit/fixtures/type.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class list(Generic[T]): pass
1313
class type(Generic[T]):
1414
__name__: str
1515
def __or__(self, other: Union[type, None]) -> type: pass
16+
def __ror__(self, other: Union[type, None]) -> type: pass
1617
def mro(self) -> List['type']: pass
1718

1819
class tuple(Generic[T]): pass

test-data/unit/fixtures/typing-full.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,5 @@ class _TypedDict(Mapping[str, object]):
179179
def pop(self, k: NoReturn, default: T = ...) -> object: ...
180180
def update(self: T, __m: T) -> None: ...
181181
def __delitem__(self, k: NoReturn) -> None: ...
182+
183+
class _SpecialForm: pass

test-data/unit/fixtures/typing-medium.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,6 @@ class ContextManager(Generic[T]):
6868
# Use Any because not all the precise types are in the fixtures.
6969
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> Any: pass
7070

71+
class _SpecialForm: pass
72+
7173
TYPE_CHECKING = 1

test-data/unit/lib-stub/_decimal.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Very simplified decimal stubs for use in tests
2+
3+
class Decimal:
4+
def __new__(cls, value: str = ...) -> Decimal: ...

test-data/unit/lib-stub/datetime.pyi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Very simplified datetime stubs for use in tests
2+
3+
class datetime:
4+
def __new__(
5+
cls,
6+
year: int,
7+
month: int,
8+
day: int,
9+
hour: int = ...,
10+
minute: int = ...,
11+
second: int = ...,
12+
microsecond: int = ...,
13+
*,
14+
fold: int = ...,
15+
) -> datetime: ...
16+
def __format__(self, __fmt: str) -> str: ...

test-data/unit/lib-stub/decimal.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Very simplified decimal stubs for use in tests
2+
3+
from _decimal import *

test-data/unit/lib-stub/functools.pyi

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from typing import Generic, TypeVar, Callable, Any, Mapping
2+
3+
_T = TypeVar("_T")
4+
5+
class _SingleDispatchCallable(Generic[_T]):
6+
registry: Mapping[Any, Callable[..., _T]]
7+
def dispatch(self, cls: Any) -> Callable[..., _T]: ...
8+
# @fun.register(complex)
9+
# def _(arg, verbose=False): ...
10+
@overload
11+
def register(self, cls: type[Any], func: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
12+
# @fun.register
13+
# def _(arg: int, verbose=False):
14+
@overload
15+
def register(self, cls: Callable[..., _T], func: None = ...) -> Callable[..., _T]: ...
16+
# fun.register(int, lambda x: x)
17+
@overload
18+
def register(self, cls: type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ...
19+
def _clear_cache(self) -> None: ...
20+
def __call__(__self, *args: Any, **kwargs: Any) -> _T: ...
21+
22+
def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ...
23+
24+
def total_ordering(cls: type[_T]) -> type[_T]: ...
25+
26+
class cached_property(Generic[_T]):
27+
func: Callable[[Any], _T]
28+
attrname: str | None
29+
def __init__(self, func: Callable[[Any], _T]) -> None: ...
30+
@overload
31+
def __get__(self, instance: None, owner: type[Any] | None = ...) -> cached_property[_T]: ...
32+
@overload
33+
def __get__(self, instance: object, owner: type[Any] | None = ...) -> _T: ...
34+
def __set_name__(self, owner: type[Any], name: str) -> None: ...
35+
def __class_getitem__(cls, item: Any) -> Any: ...

test-data/unit/lib-stub/traceback.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Very simplified traceback stubs for use in tests
2+
3+
def print_tb(*args, **kwargs) -> None: ...

0 commit comments

Comments
 (0)
0