diff --git a/crates/ty_python_semantic/resources/mdtest/narrow/match.md b/crates/ty_python_semantic/resources/mdtest/narrow/match.md index ed3e9e22bf66c4..8d95a1d5404f25 100644 --- a/crates/ty_python_semantic/resources/mdtest/narrow/match.md +++ b/crates/ty_python_semantic/resources/mdtest/narrow/match.md @@ -118,32 +118,6 @@ def f(x: Covariant[int]): assert_never(x) ``` -## Class patterns where the class pattern does not resolve to a class - -In general this does not allow for narrowing, but we make an exception for `Any`. This is to support -[real ecosystem code](https://github.com/jax-ml/jax/blob/d2ce04b6c3d03ae18b145965b8b8b92e09e8009c/jax/_src/pallas/mosaic_gpu/lowering.py#L3372-L3387) -found in `jax`. - -```py -from typing import Any - -X = Any - -def f(obj: object): - match obj: - case int(): - reveal_type(obj) # revealed: int - case X(): - reveal_type(obj) # revealed: Any & ~int - -def g(obj: object, Y: Any): - match obj: - case int(): - reveal_type(obj) # revealed: int - case Y(): - reveal_type(obj) # revealed: Any & ~int -``` - ## Value patterns Value patterns are evaluated by equality, which is overridable. Therefore successfully matching on diff --git a/crates/ty_python_semantic/src/types/narrow.rs b/crates/ty_python_semantic/src/types/narrow.rs index 56d83b8a0285b2..8f7caed22272a8 100644 --- a/crates/ty_python_semantic/src/types/narrow.rs +++ b/crates/ty_python_semantic/src/types/narrow.rs @@ -1497,7 +1497,6 @@ impl<'db, 'ast> NarrowingConstraintsBuilder<'db, 'ast> { .negate_if(self.db, !is_positive) } dynamic @ Type::Dynamic(_) => dynamic, - Type::SpecialForm(SpecialFormType::Any) => Type::any(), _ => return None, };