Skip to content

Commit

Permalink
[red-knot] Move intersection type tests to Markdown (#15396)
Browse files Browse the repository at this point in the history
## Summary

[**Rendered version of the new test
suite**](https://github.com/astral-sh/ruff/blob/david/intersection-type-tests/crates/red_knot_python_semantic/resources/mdtest/intersection_types.md)

Moves most of our existing intersection-types tests to a dedicated
Markdown test suite, extends the test coverage, unifies the notation for
these tests, groups tests into a proper structure, and adds some
explanations for various simplification strategies.

This changeset also:
- Adds a new simplification where `~Never` is removed from
intersections.
- Adds a new simplification where adding `~object` simplifies the whole
intersection to `Never`
- Avoids unnecessary assignment-checks between inferred and declared
type. This was added to this changeset to avoid many false positive
errors in this test suite.

Resolves the task described in this old comment
[here](https://github.com/astral-sh/ruff/pull/13962/files/e01da82a5a0ef6a2af0aa4dc50f898cffadb4a33..e7e432bca2b3f24979da55a9a34ad765aaaae8d1#r1819924085).

## Test Plan

Running the new Markdown tests

---------

Co-authored-by: Alex Waygood <[email protected]>
  • Loading branch information
sharkdp and AlexWaygood authored Jan 10, 2025
1 parent b861551 commit f2c3ddc
Show file tree
Hide file tree
Showing 4 changed files with 888 additions and 620 deletions.
Loading

0 comments on commit f2c3ddc

Please sign in to comment.