Skip to content

Commit 7a3f21d

Browse files
committed
fix list.copy to use the expected type
1 parent bf484ab commit 7a3f21d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

stdlib/@tests/test_cases/builtins/check_list.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ def asd(self) -> int:
1919
assert_type(combined, List[Union[Foo, Bar]])
2020
for item in combined:
2121
assert_type(item.asd(), int)
22+
23+
l1: list[int] = [1]
24+
l2: list[object] = l1.copy()

stdlib/builtins.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ class list(MutableSequence[_T]):
11041104
def __init__(self) -> None: ...
11051105
@overload
11061106
def __init__(self, iterable: Iterable[_T], /) -> None: ...
1107-
def copy(self) -> list[_T]: ...
1107+
def copy(self) -> list[_S | _T]: ...
11081108
def append(self, object: _T, /) -> None: ...
11091109
def extend(self, iterable: Iterable[_T], /) -> None: ...
11101110
def pop(self, index: SupportsIndex = -1, /) -> _T: ...

0 commit comments

Comments
 (0)