ruff/crates/ty_python_semantic/src
David Peter 4e68dd96a6
[ty] Infer types for ty_extensions.Intersection[A, B] tuple expressions (#18321)
## Summary

fixes astral-sh/ty#366

## Test Plan

* Added panic corpus regression tests
* I also wrote a hover regression test (see below), but decided not to
include it. The corpus tests are much more "effective" at finding these
types of errors, since they exhaustively check all expressions for
types.

<details>

```rs
#[test]
fn hover_regression_test_366() {
    let test = cursor_test(
        r#"
    from ty_extensions import Intersection

    class A: ...
    class B: ...

    def _(x: Intersection[A,<CURSOR> B]):
        pass
    "#,
    );

    assert_snapshot!(test.hover(), @r"
    A & B
    ---------------------------------------------
    ```text
    A & B
    ```
    ---------------------------------------------
    info[hover]: Hovered content is
     --> main.py:7:31
      |
    5 |         class B: ...
    6 |
    7 |         def _(x: Intersection[A, B]):
      |                               ^^-^
      |                               | |
      |                               | Cursor offset
      |                               source
    8 |             pass
      |
    ");
}
```

</details>
2025-05-26 17:08:52 +02:00
..
module_resolver [ty] Tell the user why we inferred the Python version we inferred (#18082) 2025-05-21 11:06:27 -04:00
semantic_index [ty] Add a subdiagnostic if invalid-return-type is emitted on a method with an empty body on a non-protocol subclass of a protocol class (#18243) 2025-05-21 17:38:07 +00:00
types [ty] Infer types for ty_extensions.Intersection[A, B] tuple expressions (#18321) 2025-05-26 17:08:52 +02:00
util Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ast_node_ref.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
db.rs [ty] Tell the user why we inferred the Python version we inferred (#18082) 2025-05-21 11:06:27 -04:00
dunder_all.rs [ty] Support import <namespace> and from <namespace> import module (#18137) 2025-05-21 07:28:33 +00:00
lib.rs [ty] Tell the user why we inferred the Python version we inferred (#18082) 2025-05-21 11:06:27 -04:00
lint.rs [ty] Ignore possibly-unresolved-reference by default (#17934) 2025-05-08 17:44:56 +02:00
list.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
module_name.rs Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
node_key.rs Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
program.rs [ty] Resolving Python path using CONDA_PREFIX variable to support Conda and Pixi (#18267) 2025-05-23 20:00:42 +02:00
python_platform.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
semantic_index.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
semantic_model.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
site_packages.rs [ty] Resolving Python path using CONDA_PREFIX variable to support Conda and Pixi (#18267) 2025-05-23 20:00:42 +02:00
suppression.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
symbol.rs [ty] Support import <namespace> and from <namespace> import module (#18137) 2025-05-21 07:28:33 +00:00
types.rs [ty] Always pass NO_INSTANCE_FALLBACK in try_call_dunder_with_policy (#18315) 2025-05-26 13:20:27 +02:00
unpack.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00