ruff/crates/ty_python_semantic/resources/mdtest
Douglas Creager c3de8847d5
[ty] Consider domain of BDD when checking whether always satisfiable (#21050)
That PR title might be a bit inscrutable.

Consider the two constraints `T ≤ bool` and `T ≤ int`. Since `bool ≤
int`, by transitivity `T ≤ bool` implies `T ≤ int`. (Every type that is
a subtype of `bool` is necessarily also a subtype of `int`.) That means
that `T ≤ bool ∧ T ≰ int` is an impossible combination of constraints,
and is therefore not a valid input to any BDD. We say that that
assignment is not in the _domain_ of the BDD.

The implication `T ≤ bool → T ≤ int` can be rewritten as `T ≰ bool ∨ T ≤
int`. (That's the definition of implication.) If we construct that
constraint set in an mdtest, we should get a constraint set that is
always satisfiable. Previously, that constraint set would correctly
_display_ as `always`, but a `static_assert` on it would fail.

The underlying cause is that our `is_always_satisfied` method would only
test if the BDD was the `AlwaysTrue` terminal node. `T ≰ bool ∨ T ≤ int`
does not simplify that far, because we purposefully keep around those
constraints in the BDD structure so that it's easier to compare against
other BDDs that reference those constraints.

To fix this, we need a more nuanced definition of "always satisfied".
Instead of evaluating to `true` for _every_ input, we only need it to
evaluate to `true` for every _valid_ input — that is, every input in its
domain.
2025-10-24 13:37:56 -04:00
..
annotations [ty] Infer type for implicit self parameters in method bodies (#20922) 2025-10-23 09:34:39 +02:00
assignment [ty] Prefer declared type for invariant collection literals (#20927) 2025-10-16 16:11:28 -04:00
binary [ty] Sync vendored typeshed stubs (#20876) 2025-10-15 11:13:32 +02:00
boolean
boundness_declaredness
call [ty] Avoid duplicate diagnostics during multi-inference of standalone expressions (#21056) 2025-10-24 13:21:39 -04:00
class [ty] Infer type for implicit self parameters in method bodies (#20922) 2025-10-23 09:34:39 +02:00
comparison
comprehensions
conditional
dataclasses [ty] dataclass_transform: Support for fields with an alias (#20961) 2025-10-18 18:20:39 +00:00
declaration
diagnostics [ty] continue and break statements outside loops are syntax errors (#20944) 2025-10-17 17:13:40 +00:00
directives
doc
exception [ty] Filter out revealed-type and undefined-reveal diagnostics from mdtest snapshots (#20820) 2025-10-12 18:39:32 +00:00
expression [ty] Delegate truthiness inference of an enum Literal type to its enum-instance supertype (#21060) 2025-10-24 14:34:16 +01:00
function
generics [ty] fix infinite recursion with generic type aliases (#20969) 2025-10-23 14:14:30 +00:00
ide_support [ty] Filter out revealed-type and undefined-reveal diagnostics from mdtest snapshots (#20820) 2025-10-12 18:39:32 +00:00
import [ty] Improve error messages for unresolved attribute diagnostics (#20963) 2025-10-19 10:58:25 +01:00
literal [ty] Treat functions, methods, and dynamic types as function-like Callables (#20842) 2025-10-13 15:21:55 +02:00
loops [ty] Heterogeneous unpacking support for unions (#20377) 2025-10-15 19:30:03 +01:00
narrow [ty] Consider __len__ when determining the truthiness of an instance of a tuple class or a @final class (#21049) 2025-10-24 09:29:55 +00:00
regression [ty] Fix rare panic with highly cyclic TypeVar definitions (#21059) 2025-10-24 18:30:54 +02:00
scopes [ty] Improve error messages for unresolved attribute diagnostics (#20963) 2025-10-19 10:58:25 +01:00
shadowing
snapshots [ty] Improve invalid-argument-type diagnostics where a union type was provided (#21044) 2025-10-23 13:16:21 +00:00
stubs
subscript
suppressions [ty] Add suggestion to unknown rule diagnostics, rename unknown-rule lint to ignore-comment-unknown-rule (#20948) 2025-10-18 12:44:21 +02:00
type_compendium [ty] Heterogeneous unpacking support for unions (#20377) 2025-10-15 19:30:03 +01:00
type_of
type_properties [ty] Consider domain of BDD when checking whether always satisfiable (#21050) 2025-10-24 13:37:56 -04:00
type_qualifiers [ty] Infer type for implicit self parameters in method bodies (#20922) 2025-10-23 09:34:39 +02:00
unary
with
.mdformat.toml
async.md
attributes.md [ty] Infer type for implicit self parameters in method bodies (#20922) 2025-10-23 09:34:39 +02:00
bidirectional.md [ty] bidirectional type inference using function return type annotations (#20528) 2025-10-11 00:38:35 +00:00
classes.md
cycle.md [ty] Avoid ever-growing default types (#20991) 2025-10-21 19:13:36 +02:00
decorators.md
del.md
deprecated.md
descriptor_protocol.md [ty] Infer type for implicit self parameters in method bodies (#20922) 2025-10-23 09:34:39 +02:00
enums.md
exhaustiveness_checking.md
final.md
implicit_type_aliases.md
instance_layout_conflict.md
intersection_types.md
invalid_syntax.md
known_constants.md
mdtest_config.md
mdtest_custom_typeshed.md
metaclass.md
mro.md [ty] Filter out revealed-type and undefined-reveal diagnostics from mdtest snapshots (#20820) 2025-10-12 18:39:32 +00:00
named_tuple.md [ty] Infer type for implicit self parameters in method bodies (#20922) 2025-10-23 09:34:39 +02:00
overloads.md
pep613_type_aliases.md [ty] Fall back to Divergent for deeply nested specializations (#20988) 2025-10-22 14:29:10 +02:00
pep695_type_aliases.md [ty] Add cycle handling to lazy_default (#20967) 2025-10-23 10:05:08 +02:00
properties.md
protocols.md [ty] Fix panic when attempting to validate the members of a protocol that inherits from a protocol in another module (#20956) 2025-10-18 15:01:46 +01:00
public_types.md [ty] Disambiguate classes that live in different modules but have the same fully qualified names (#20756) 2025-10-08 18:27:40 +01:00
statically_known_branches.md
sys_platform.md
sys_version_info.md
t_strings.md
terminal_statements.md
ty_extensions.md [ty] Simplify and fix CallableTypeOf[..] implementation (#20797) 2025-10-10 12:04:37 +02:00
typed_dict.md [ty] Improve error messages for unresolved attribute diagnostics (#20963) 2025-10-19 10:58:25 +01:00
union_types.md
unpacking.md
unreachable.md