mirror of https://github.com/astral-sh/ruff
codex 2
This commit is contained in:
parent
8655598901
commit
86271d605d
|
|
@ -43,7 +43,7 @@ def unbounded[T]():
|
||||||
# revealed: None
|
# revealed: None
|
||||||
reveal_type(generic_context(unbounded).specialize_constrained(ConstraintSet.range(bool, T, bool) & ConstraintSet.range(Never, T, str)))
|
reveal_type(generic_context(unbounded).specialize_constrained(ConstraintSet.range(bool, T, bool) & ConstraintSet.range(Never, T, str)))
|
||||||
|
|
||||||
# revealed: ty_extensions.Specialization[T@unbounded = int]
|
# revealed: ty_extensions.Specialization[T@unbounded = bool]
|
||||||
reveal_type(generic_context(unbounded).specialize_constrained(ConstraintSet.range(Never, T, int) | ConstraintSet.range(Never, T, bool)))
|
reveal_type(generic_context(unbounded).specialize_constrained(ConstraintSet.range(Never, T, int) | ConstraintSet.range(Never, T, bool)))
|
||||||
# revealed: ty_extensions.Specialization[T@unbounded = Never]
|
# revealed: ty_extensions.Specialization[T@unbounded = Never]
|
||||||
reveal_type(generic_context(unbounded).specialize_constrained(ConstraintSet.range(Never, T, int) | ConstraintSet.range(Never, T, str)))
|
reveal_type(generic_context(unbounded).specialize_constrained(ConstraintSet.range(Never, T, int) | ConstraintSet.range(Never, T, str)))
|
||||||
|
|
@ -310,18 +310,18 @@ def constrained_by_gradual_list[T: (list[Base], list[Any])]():
|
||||||
# Same tests as above, but with the typevar constraints in a different order, to make sure the
|
# Same tests as above, but with the typevar constraints in a different order, to make sure the
|
||||||
# results do not depend on our BDD variable ordering.
|
# results do not depend on our BDD variable ordering.
|
||||||
def constrained_by_gradual_list_reverse[T: (list[Any], list[Base])]():
|
def constrained_by_gradual_list_reverse[T: (list[Any], list[Base])]():
|
||||||
# revealed: ty_extensions.Specialization[T@constrained_by_gradual_list_reverse = Top[list[Any]]]
|
# revealed: ty_extensions.Specialization[T@constrained_by_gradual_list_reverse = list[Base]]
|
||||||
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.always()))
|
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.always()))
|
||||||
# revealed: ty_extensions.Specialization[T@constrained_by_gradual_list_reverse = list[object]]
|
# revealed: ty_extensions.Specialization[T@constrained_by_gradual_list_reverse = list[object]]
|
||||||
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.range(Never, T, list[object])))
|
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.range(Never, T, list[object])))
|
||||||
# revealed: ty_extensions.Specialization[T@constrained_by_gradual_list_reverse = list[Any]]
|
# revealed: ty_extensions.Specialization[T@constrained_by_gradual_list_reverse = list[Base] & list[Any]]
|
||||||
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.range(Never, T, list[Any])))
|
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.range(Never, T, list[Any])))
|
||||||
# revealed: None
|
# revealed: None
|
||||||
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.never()))
|
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.never()))
|
||||||
|
|
||||||
# revealed: ty_extensions.Specialization[T@constrained_by_gradual_list_reverse = list[Base]]
|
# revealed: ty_extensions.Specialization[T@constrained_by_gradual_list_reverse = list[Base]]
|
||||||
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.range(Never, T, list[Base])))
|
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.range(Never, T, list[Base])))
|
||||||
# revealed: ty_extensions.Specialization[T@constrained_by_gradual_list_reverse = Top[list[Any]]]
|
# revealed: ty_extensions.Specialization[T@constrained_by_gradual_list_reverse = list[Base]]
|
||||||
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.range(list[Base], T, object)))
|
reveal_type(generic_context(constrained_by_gradual_list_reverse).specialize_constrained(ConstraintSet.range(list[Base], T, object)))
|
||||||
|
|
||||||
# TODO: revealed: ty_extensions.Specialization[T@constrained_by_gradual = list[Any]]
|
# TODO: revealed: ty_extensions.Specialization[T@constrained_by_gradual = list[Any]]
|
||||||
|
|
|
||||||
|
|
@ -1079,8 +1079,21 @@ impl<'db> Node<'db> {
|
||||||
|
|
||||||
fn or_with_rhs_offset(self, db: &'db dyn Db, other: Self, rhs_offset: usize) -> Self {
|
fn or_with_rhs_offset(self, db: &'db dyn Db, other: Self, rhs_offset: usize) -> Self {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Node::AlwaysTrue, _) => Node::AlwaysTrue,
|
(Node::AlwaysTrue, Node::AlwaysTrue) => Node::AlwaysTrue,
|
||||||
(_, Node::AlwaysTrue) => Node::AlwaysTrue,
|
(Node::AlwaysTrue, Node::Interior(rhs)) => Node::new(
|
||||||
|
db,
|
||||||
|
rhs.constraint(db),
|
||||||
|
Node::AlwaysTrue,
|
||||||
|
Node::AlwaysTrue,
|
||||||
|
rhs.source_order(db) + rhs_offset,
|
||||||
|
),
|
||||||
|
(Node::Interior(lhs), Node::AlwaysTrue) => Node::new(
|
||||||
|
db,
|
||||||
|
lhs.constraint(db),
|
||||||
|
Node::AlwaysTrue,
|
||||||
|
Node::AlwaysTrue,
|
||||||
|
lhs.source_order(db),
|
||||||
|
),
|
||||||
(Node::AlwaysFalse, rhs) => rhs.with_source_order_offset(db, rhs_offset),
|
(Node::AlwaysFalse, rhs) => rhs.with_source_order_offset(db, rhs_offset),
|
||||||
(lhs, Node::AlwaysFalse) => lhs,
|
(lhs, Node::AlwaysFalse) => lhs,
|
||||||
(Node::Interior(lhs), Node::Interior(rhs)) => lhs.or(db, rhs, rhs_offset),
|
(Node::Interior(lhs), Node::Interior(rhs)) => lhs.or(db, rhs, rhs_offset),
|
||||||
|
|
@ -1095,8 +1108,21 @@ impl<'db> Node<'db> {
|
||||||
|
|
||||||
fn and_with_rhs_offset(self, db: &'db dyn Db, other: Self, rhs_offset: usize) -> Self {
|
fn and_with_rhs_offset(self, db: &'db dyn Db, other: Self, rhs_offset: usize) -> Self {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Node::AlwaysFalse, _) => Node::AlwaysFalse,
|
(Node::AlwaysFalse, Node::AlwaysFalse) => Node::AlwaysFalse,
|
||||||
(_, Node::AlwaysFalse) => Node::AlwaysFalse,
|
(Node::AlwaysFalse, Node::Interior(rhs)) => Node::new(
|
||||||
|
db,
|
||||||
|
rhs.constraint(db),
|
||||||
|
Node::AlwaysFalse,
|
||||||
|
Node::AlwaysFalse,
|
||||||
|
rhs.source_order(db) + rhs_offset,
|
||||||
|
),
|
||||||
|
(Node::Interior(lhs), Node::AlwaysFalse) => Node::new(
|
||||||
|
db,
|
||||||
|
lhs.constraint(db),
|
||||||
|
Node::AlwaysFalse,
|
||||||
|
Node::AlwaysFalse,
|
||||||
|
lhs.source_order(db),
|
||||||
|
),
|
||||||
(Node::AlwaysTrue, rhs) => rhs.with_source_order_offset(db, rhs_offset),
|
(Node::AlwaysTrue, rhs) => rhs.with_source_order_offset(db, rhs_offset),
|
||||||
(lhs, Node::AlwaysTrue) => lhs,
|
(lhs, Node::AlwaysTrue) => lhs,
|
||||||
(Node::Interior(lhs), Node::Interior(rhs)) => lhs.and(db, rhs, rhs_offset),
|
(Node::Interior(lhs), Node::Interior(rhs)) => lhs.and(db, rhs, rhs_offset),
|
||||||
|
|
@ -3676,14 +3702,26 @@ mod tests {
|
||||||
fn test_display_graph_output() {
|
fn test_display_graph_output() {
|
||||||
let expected = indoc! {r#"
|
let expected = indoc! {r#"
|
||||||
(T = str)
|
(T = str)
|
||||||
┡━₁ (U = str)
|
┡━₁ (T = bool)
|
||||||
│ ┡━₁ always
|
│ ┡━₁ (U = str)
|
||||||
|
│ │ ┡━₁ (U = bool)
|
||||||
|
│ │ │ ┡━₁ always
|
||||||
|
│ │ │ └─₀ always
|
||||||
|
│ │ └─₀ (U = bool)
|
||||||
|
│ │ ┡━₁ always
|
||||||
|
│ │ └─₀ never
|
||||||
|
│ └─₀ (U = str)
|
||||||
|
│ ┡━₁ (U = bool)
|
||||||
|
│ │ ┡━₁ always
|
||||||
|
│ │ └─₀ always
|
||||||
│ └─₀ (U = bool)
|
│ └─₀ (U = bool)
|
||||||
│ ┡━₁ always
|
│ ┡━₁ always
|
||||||
│ └─₀ never
|
│ └─₀ never
|
||||||
└─₀ (T = bool)
|
└─₀ (T = bool)
|
||||||
┡━₁ (U = str)
|
┡━₁ (U = str)
|
||||||
│ ┡━₁ always
|
│ ┡━₁ (U = bool)
|
||||||
|
│ │ ┡━₁ always
|
||||||
|
│ │ └─₀ always
|
||||||
│ └─₀ (U = bool)
|
│ └─₀ (U = bool)
|
||||||
│ ┡━₁ always
|
│ ┡━₁ always
|
||||||
│ └─₀ never
|
│ └─₀ never
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue