ruff/crates/red_knot_python_semantic/resources/mdtest/annotations
Carl Meyer 1918c61623
[red-knot] class bases are not affected by __future__.annotations (#17456)
## Summary

We were over-conflating the conditions for deferred name resolution.
`from __future__ import annotations` defers annotations, but not class
bases. In stub files, class bases are also deferred. Modeling this
correctly also reduces likelihood of cycles in Python files using `from
__future__ import annotations` (since deferred resolution is inherently
cycle-prone). The same cycles are still possible in `.pyi` files, but
much less likely, since typically there isn't anything in a `pyi` file
that would cause an early return from a scope, or otherwise cause
visibility constraints to persist to end of scope. Usually there is only
code at module global scope and class scope, which can't have `return`
statements, and `raise` or `assert` statements in a stub file would be
very strange. (Technically according to the spec we'd be within our
rights to just forbid a whole bunch of syntax outright in a stub file,
but I kinda like minimizing unnecessary differences between the handling
of Python files and stub files.)

## Test Plan

Added mdtests.
2025-04-18 06:46:21 -07:00
..
annotated.md Special-case value-expression inference of special form subscriptions (#16877) 2025-03-20 21:46:02 +00:00
any.md [red-knot] Understand Annotated (#14950) 2024-12-13 09:41:37 -08:00
callable.md [red-knot] Detect version-related syntax errors (#16379) 2025-04-17 14:00:30 -04:00
deferred.md [red-knot] class bases are not affected by __future__.annotations (#17456) 2025-04-18 06:46:21 -07:00
int_float_complex.md Use python.typing.org for typing documentation links (#17323) 2025-04-09 20:38:20 +02:00
invalid.md [red-knot] Ban most Type::Instance types in type expressions (#16872) 2025-03-20 15:19:56 -07:00
literal.md [red-knot] optimize building large unions of literals (#17403) 2025-04-16 13:55:37 +00:00
literal_string.md [red-knot] Add support for overloaded functions (#17366) 2025-04-18 09:57:40 +05:30
never.md [red-knot] Statically known branches (#15019) 2024-12-21 11:33:10 +01:00
new_types.md red_knot_python_semantic: replace one use of "old" secondary diagnostic messages 2025-04-10 13:21:00 -04:00
optional.md [red-knot] Make' Type::in_type_expression()' exhaustive for Type::KnownInstance (#16836) 2025-03-19 07:36:28 -07:00
starred.md [red-knot] Detect version-related syntax errors (#16379) 2025-04-17 14:00:30 -04:00
stdlib_typing_aliases.md [red-knot] Add initial support for * imports (#16923) 2025-03-24 17:15:58 +00:00
string.md [red-knot] optimize building large unions of literals (#17403) 2025-04-16 13:55:37 +00:00
union.md [red-knot] Fix false positives on types.UnionType instances in type expressions (#17297) 2025-04-09 18:33:16 +01:00
unsupported_special_forms.md [red-knot] Detect version-related syntax errors (#16379) 2025-04-17 14:00:30 -04:00
unsupported_type_qualifiers.md Show more precise messages in invalid type expressions (#16850) 2025-03-19 17:00:30 +00:00