Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test-data/unit/check-redefine.test
Original file line number Diff line number Diff line change
Expand Up @@ -636,3 +636,11 @@ def _(arg: str) -> str: # E: Name "_" already defined (possibly by an import)
[file a.py]
def f(s: str) -> str:
return s

[case testRedefineListComprehension]
# flags: --allow-redefinition
def process(items: list[str]) -> None:
reveal_type(items) # N: Revealed type is "builtins.list[builtins.str]"
items = [item.split() for item in items]
reveal_type(items) # N: Revealed type is "builtins.list[builtins.list[builtins.str]]"
[builtins fixtures/primitives.pyi]
8 changes: 8 additions & 0 deletions test-data/unit/check-redefine2.test
Original file line number Diff line number Diff line change
Expand Up @@ -1197,3 +1197,11 @@ x = 0
if int():
x = ""
reveal_type(x) # N: Revealed type is "builtins.int | builtins.str"

[case testNewRedefineListComprehension]
# flags: --allow-redefinition-new --local-partial-types
def process(items: list[str]) -> None:
reveal_type(items) # N: Revealed type is "builtins.list[builtins.str]"
items = [item.split() for item in items]
reveal_type(items) # N: Revealed type is "builtins.list[builtins.list[builtins.str]]"
[builtins fixtures/primitives.pyi]
2 changes: 2 additions & 0 deletions test-data/unit/fixtures/primitives.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class str(Sequence[str]):
def __contains__(self, other: object) -> bool: pass
def __getitem__(self, item: int) -> str: pass
def format(self, *args: object, **kwargs: object) -> str: pass
# Note: this is a simplification of the actual signature
def split(self, sep: str | None = None) -> list[str]: pass
class bytes(Sequence[int]):
def __iter__(self) -> Iterator[int]: pass
def __contains__(self, other: object) -> bool: pass
Expand Down
Loading