ruff/crates/ty_python_semantic/resources/mdtest
David Peter 04457f99b6
[ty] Protocols: Fixpoint iteration for fully-static check (#17880)
## Summary

A recursive protocol like the following would previously lead to stack
overflows when attempting to create the union type for the `P | None`
member, because `UnionBuilder` checks if element types are fully static,
and the fully-static check on `P` would in turn list all members and
check whether all of them were fully static, leading to a cycle.

```py
from __future__ import annotations

from typing import Protocol

class P(Protocol):
    parent: P | None
```

Here, we make the fully-static check on protocols a salsa query and add
fixpoint iteration, starting with `true` as the initial value (assume
that the recursive protocol is fully-static). If the recursive protocol
has any non-fully-static members, we still return `false` when
re-executing the query (see newly added tests).

closes #17861

## Test Plan

Added regression test
2025-05-07 08:55:21 +02:00
..
annotations Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
assignment Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
binary Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
boolean Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
boundness_declaredness Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
call Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
class Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
comparison Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
comprehensions Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
conditional Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
declaration Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
diagnostics [semantic-syntax-tests] for for InvalidStarExpression, DuplicateMatchKey, and DuplicateMatchClassAttribute (#17754) 2025-05-05 17:30:16 +00:00
directives Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
doc Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
exception Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
expression Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
function [ty] Fix false-positive [invalid-return-type] diagnostics on generator functions (#17871) 2025-05-05 21:44:59 +00:00
generics Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
import Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
literal Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
loops Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
narrow Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
regression Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
scopes Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
shadowing Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
snapshots Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
stubs Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
subscript Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
suppressions Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
type_of Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
type_properties Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
type_qualifiers Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
unary Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
with Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
.mdformat.toml Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
attributes.md Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
cycle.md [ty] add cycle handling for FunctionType::signature query (#17833) 2025-05-05 12:12:38 -07:00
dataclass_transform.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
dataclasses.md Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
decorators.md [ty] Specialize bound methods and nominal instances (#17865) 2025-05-05 17:17:36 -04:00
descriptor_protocol.md Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
final.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
intersection_types.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
invalid_syntax.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
known_constants.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
mdtest_config.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
mdtest_custom_typeshed.md [ty] Fix duplicate diagnostics for unresolved module when an import from statement imports multiple members (#17886) 2025-05-06 12:37:10 +01:00
metaclass.md Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
mro.md Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
named_tuple.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
overloads.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
pep695_type_aliases.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
properties.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
protocols.md [ty] Protocols: Fixpoint iteration for fully-static check (#17880) 2025-05-07 08:55:21 +02:00
slots.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
statically_known_branches.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
sys_platform.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
sys_version_info.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
terminal_statements.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
type_api.md Update class literal display to use <class 'Foo'> style (#17889) 2025-05-06 20:11:25 -04:00
typed_dict.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
union_types.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
unpacking.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
unreachable.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00