ruff
9e0189bb - [ty] remove special handling for `Any()` in match class patterns (#23011)

Commit
234 days ago
[ty] remove special handling for `Any()` in match class patterns (#23011) ## Summary `Any` does not support `isinstance` checks and cannot be used in class patterns. If the arm with `Any()` is hit, it will raise an error at runtime: ```py [nav] In [1]: from typing import Any ...: ...: X = Any ...: ...: def f(obj: object): ...: match obj: ...: case int(): ...: ... ...: case X(): ...: ... [ins] In [2]: f("") --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[2], line 1 ----> 1 f("") Cell In[1], line 9, in f(obj) 7 case int(): 8 ... ----> 9 case X(): 10 ... # << snipped for brevity >> TypeError: typing.Any cannot be used with isinstance() ``` Because this fails at runtime, we should ideally raise a diagnostic on seeing `Any()` in a match pattern. That could potentially be done as part of https://github.com/astral-sh/ty/issues/2592. But for now, this PR only removes the special support that we have. The special-case handling does not reduce any diagnostics on `jax` as of today either. ## Test Plan Removed tests :)
Parents
Loading