Skip to content

Commit e6bd09f

Browse files
committed
some review comments
1 parent f3cf087 commit e6bd09f

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

crates/ty_python_semantic/src/types.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9006,7 +9006,7 @@ pub(crate) enum TypeRelation {
90069006
/// subtype of `C` if and only if the union of all possible sets of values
90079007
/// represented by `D` (the "top materialization" of `D`) is a subtype of the
90089008
/// intersection of all possible sets of values represented by `C` (the "bottom
9009-
/// materialization" of `C`).
9009+
/// materialization" of `C`). More concisely: `D <: C` iff `Top[D] <: Bottom[C]`.
90109010
///
90119011
/// For example, `list[Any]` can be said to be a subtype of `Sequence[object]`,
90129012
/// because every possible fully static materialization of `list[Any]` (`list[int]`,
@@ -9034,8 +9034,13 @@ pub(crate) enum TypeRelation {
90349034
///
90359035
/// Between a pair of `C` and `D` where either `C` or `D` is not fully static, the
90369036
/// assignability relation may be more permissive than the subtyping relation. `D`
9037-
/// can be said to be assignable to `C` if *any* possibly fully static [materialization]
9038-
/// of `D` is a subtype of *any* possible fully static materialization of `C`.
9037+
/// can be said to be assignable to `C` if *some* possible fully static [materialization]
9038+
/// of `D` is a subtype of *some* possible fully static materialization of `C`.
9039+
/// Another way of saying this is that `D` will be assignable to `C` if and only if the
9040+
/// intersection of all possible sets of values represented by `D` (the "bottom
9041+
/// materialization" of `D`) is a subtype of the union of all possible sets of values
9042+
/// represented by `C` (the "top materialization" of `C`).
9043+
/// More concisely: `D <: C` iff `Bottom[D] <: Top[C]`.
90399044
///
90409045
/// For example, `Any` is not a subtype of `int`, because there are possible
90419046
/// materializations of `Any` (e.g., `str`) that are not subtypes of `int`.
@@ -9062,17 +9067,16 @@ pub(crate) enum TypeRelation {
90629067
/// pragmatically simplified to the type `A` without downstream consequences on ty's
90639068
/// inference of types elsewhere.
90649069
///
9065-
/// For a pair of [fully static] types `A` and `B`, the assignability relation
9070+
/// For a pair of [fully static] types `A` and `B`, the union simplification relation
90669071
/// between `A` and `B` is the same as the subtyping relation.
90679072
///
90689073
/// Between a pair of `C` and `D` where either `C` or `D` is not fully static, the
90699074
/// union simplification relation sits in between the subtyping relation and the
9070-
/// assignability relation. `D` can be said to be redundant in a union with `C` if either:
9071-
///
9072-
/// 1. `D` is a subtype of `C`; or,
9073-
/// 2. The top materialization of the type `C | D` is equivalent to the top
9074-
/// materialization of `C`, *and* the bottom materialization of `C | D` is equivalent
9075-
/// to the bottom materialization of `C`.
9075+
/// assignability relation. `D` can be said to be redundant in a union with `C` if the
9076+
/// top materialization of the type `C | D` is equivalent to the top materialization of
9077+
/// `C`, *and* the bottom materialization of `C | D` is equivalent to the bottom
9078+
/// materialization of `C`.
9079+
/// More concisely: `D <: C` iff `Top[C | D] == Top[C]` AND `Bottom[C | D] == Bottom[C]`.
90769080
///
90779081
/// Practically speaking, in most respects the union simplification relation is the
90789082
/// same as the subtyping relation. It is redundant to add `bool` to a union that

0 commit comments

Comments
 (0)