-
Notifications
You must be signed in to change notification settings - Fork 230
Closed
astral-sh/ruff
#23728Labels
genericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementationset-theoretic typesunions, intersections and moreunions, intersections and more
Milestone
Description
From #2087:
from typing import Sequence, reveal_type
def test(command: Sequence[str] | str) -> str:
reveal_type(command) # Sequence[str]
parts = map(str, command) # works
if isinstance(command, str):
return command
else:
reveal_type(command) # Sequence[str] & ~str
parts = map(str, command) # fails with "not assignable to `Iterable[Buffer]`"
return ' '.join(parts)
print(test('echo hello'))
print(test(['echo', 'hello']))The first map works, the second one fails; the only difference is the intersection with ~str. It should not be possible for that to cause the assignment to fail, if the other intersection component succeeds.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
genericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementationset-theoretic typesunions, intersections and moreunions, intersections and more