ruff/crates/red_knot_python_semantic/resources/mdtest
Alex Waygood 3950b00ee4
[red-knot] Implement disjointness for Instance types where the underlying class is @final (#15539)
## Summary

Closes https://github.com/astral-sh/ruff/issues/15508

For any two instance types `T` and `S`, we know they are disjoint if
either `T` is final and `T` is not a subclass of `S` or `S` is final and
`S` is not a subclass of `T`.

Correspondingly, for any two types `type[T]` and `S` where `S` is an
instance type, `type[T]` can be said to be disjoint from `S` if `S` is
disjoint from `U`, where `U` is the type that represents all instances
of `T`'s metaclass.

And a heterogeneous tuple type can be said to be disjoint from an
instance type if the instance type is disjoint from `tuple` (a type
representing all instances of the `tuple` class at runtime).

## Test Plan

- A new mdtest added. Most of our `is_disjoint_from()` tests are not
written as mdtests just yet, but it's pretty hard to test some of these
edge cases from a Rust unit test!
- Ran `QUICKCHECK_TESTS=1000000 cargo test --release -p
red_knot_python_semantic -- --ignored types::property_tests::stable`

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
2025-01-16 23:48:52 +00:00
..
annotations [red-knot] Migrate bool/str/repr unit tests to Markdown tests (#15534) 2025-01-16 11:21:56 -08:00
assignment [red-knot] add call checking (#15200) 2025-01-07 20:39:45 +00:00
binary Don't special-case class instances in binary expression inference (#15161) 2025-01-06 13:50:20 -05:00
boolean [red-knot] Statically known branches (#15019) 2024-12-21 11:33:10 +01:00
boundness_declaredness [red-knot] Add boundness and declaredness tests (#15453) 2025-01-14 13:07:16 +01:00
call [red-knot] remove CallOutcome::Cast variant (#15461) 2025-01-13 10:58:53 -08:00
comparison [red-knot] Simplify object out of intersections (#15511) 2025-01-15 20:06:48 +00:00
conditional [red-knot] fix control flow for assignment expressions in elif tests (#15274) 2025-01-05 18:35:29 +00:00
declaration [red-knot] Avoid undeclared path when raising conflicting declarations (#14958) 2024-12-17 09:49:39 +05:30
directives [red-knot] Support cast (#15413) 2025-01-12 13:05:45 +00:00
exception [red-knot] Report invalid exceptions (#15042) 2024-12-18 18:31:24 +00:00
expression Display Union of Literals as a Literal (#14993) 2025-01-08 00:58:38 +00:00
function [red-knot] function parameter types (#14802) 2024-12-06 12:55:56 -08:00
import Prioritize attribute in from/import statement (#15041) 2024-12-17 16:58:23 -05:00
literal [red-knot] Migrate bool/str/repr unit tests to Markdown tests (#15534) 2025-01-16 11:21:56 -08:00
loops Display Union of Literals as a Literal (#14993) 2025-01-08 00:58:38 +00:00
narrow [red-knot] Implement disjointness for Instance types where the underlying class is @final (#15539) 2025-01-16 23:48:52 +00:00
regression [red-knot] Do not attach diagnostics to wrong file (#14337) 2024-11-14 15:39:51 +01:00
scopes Display Union of Literals as a Literal (#14993) 2025-01-08 00:58:38 +00:00
shadowing Test explicit shadowing involving defs (#15174) 2024-12-29 00:47:03 +00:00
stubs Allow assigning ellipsis literal as parameter default value (#14982) 2025-01-05 13:11:32 -06:00
subscript [red-knot] Statically known branches (#15019) 2024-12-21 11:33:10 +01:00
suppressions @no_type_check support (#15122) 2024-12-30 09:42:18 +00:00
type_of [red-knot] Eagerly normalize type[] types (#15272) 2025-01-07 12:53:07 +00:00
type_properties [red-knot] Implement disjointness for Instance types where the underlying class is @final (#15539) 2025-01-16 23:48:52 +00:00
unary Don't special-case class instances in binary expression inference (#15161) 2025-01-06 13:50:20 -05:00
with [red-knot] Cleanup various todo_type!() messages (#15063) 2024-12-19 13:03:41 +00:00
.mdformat.toml [red-knot] have mdformat wrap mdtest files to 100 columns (#14020) 2024-10-31 21:00:51 +00:00
attributes.md [red-knot] Instance attributes: type inference clarifications (#15512) 2025-01-15 21:17:55 +01:00
final.md [red-knot] Add support for @final classes (#15070) 2024-12-19 21:02:14 +00:00
generics.md [red-knot] Add infrastructure to declare lints (#14873) 2024-12-10 16:14:44 +00:00
intersection_types.md [red-knot] Simplify object out of intersections (#15511) 2025-01-15 20:06:48 +00:00
invalid_syntax.md [red-knot] Separate invalid syntax code snippets (#14803) 2024-12-06 02:41:33 +00:00
known_constants.md [red-knot] Support typing.TYPE_CHECKING (#14952) 2024-12-13 09:24:48 +00:00
mdtest_config.md Rename custom-typeshed-dir, target-version and current-directory CLI options (#14930) 2024-12-13 08:21:52 +00:00
metaclass.md [red-knot] More precise inference for classes with non-class metaclasses (#15138) 2025-01-09 00:34:04 +00:00
mro.md [red-knot] Add infrastructure to declare lints (#14873) 2024-12-10 16:14:44 +00:00
pep695_type_aliases.md [red-knot] mdtest: python version requirements (#14954) 2024-12-13 10:40:38 +01:00
slots.md Don't special-case class instances in binary expression inference (#15161) 2025-01-06 13:50:20 -05:00
statically_known_branches.md [red-knot] Statically known branches (#15019) 2024-12-21 11:33:10 +01:00
sys_platform.md [red-knot] Typeshed sync and sys.platform fixes (#15492) 2025-01-15 11:21:01 +01:00
sys_version_info.md Rename custom-typeshed-dir, target-version and current-directory CLI options (#14930) 2024-12-13 08:21:52 +00:00
type_api.md [red-knot] Add AlwaysTruthy and AlwaysFalsy to knot_extensions (#15437) 2025-01-12 17:00:57 +00:00
union_types.md [red-knot] Move intersection type tests to Markdown (#15396) 2025-01-10 14:04:03 +01:00
unpacking.md Display Union of Literals as a Literal (#14993) 2025-01-08 00:58:38 +00:00