-
Notifications
You must be signed in to change notification settings - Fork 216
Open
astral-sh/ruff
#23186Labels
bidirectional inferenceInference of types that takes into account the context of a declared type or expected typeInference of types that takes into account the context of a declared type or expected type
Milestone
Description
Summary
Literal promotion is currently performed for tuple but not for frozenset. This is surprising to me given that they both are immutable and behave somewhat similarly. It could be useful to change frozenset, for instance to support the following comparisons:
from typing import reveal_type
# tuple
reveal_type((1, 2)) # Revealed type: `tuple[Literal[1], Literal[2]]`
reveal_type((1, 2) == (1, 2)) # Revealed type: `Literal[True]`
# frozenset
reveal_type(frozenset({1, 2})) # Revealed type: `frozenset[Unknown | int]`
reveal_type(frozenset({1, 2}) == frozenset({1, 2})) # Revealed type: `bool`
reveal_type(frozenset({1, 2}) == frozenset({2, 1})) # Revealed type: `bool`Related: #1284 (comment)
Version
ty 0.0.8 (aa7559d 2025-12-29)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bidirectional inferenceInference of types that takes into account the context of a declared type or expected typeInference of types that takes into account the context of a declared type or expected type