ruff/crates/red_knot_python_semantic/resources/mdtest/annotations
David Peter 8712438aec
[red-knot] Initial tests for instance attributes (#15474)
## Summary

Adds some initial tests for class and instance attributes, mostly to
document (and discuss) what we want to support eventually. These
tests are not exhaustive yet. The idea is to specify the coarse-grained
behavior first.

Things that we'll eventually want to test:

- Interplay with inheritance
- Support `Final` in addition to `ClassVar`
- Specific tests for `ClassVar`, like making sure that we support things
like `x: Annotated[ClassVar[int], "metadata"]`
- … or making sure that we raise an error here:
  ```py
  class Foo:
      def __init__(self):
          self.x: ClassVar[str] = "x"
  ```
- Add tests for `__new__` in addition to the tests for `__init__`
- Add tests that show that we use the union of types if multiple methods
define the symbol with different types
- Make sure that diagnostics are raised if, e.g., the inferred type of
an assignment within a method does not match the declared type in the
class body.
- https://github.com/astral-sh/ruff/pull/15474#discussion_r1916556284
- Method calls are completely left out for now.
- Same for `@property`
- … and the descriptor protocol

## Test Plan

New Markdown tests

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-01-15 14:43:41 +00:00
..
annotated.md [red-knot] Emit an error if a bare Annotated or Literal is used in a type expression (#14973) 2024-12-15 02:00:52 +00:00
any.md [red-knot] Understand Annotated (#14950) 2024-12-13 09:41:37 -08:00
literal.md Display Union of Literals as a Literal (#14993) 2025-01-08 00:58:38 +00:00
literal_string.md Display Union of Literals as a Literal (#14993) 2025-01-08 00:58:38 +00:00
never.md [red-knot] Statically known branches (#15019) 2024-12-21 11:33:10 +01:00
optional.md Understand typing.Optional in annotations (#14397) 2024-11-17 17:04:58 +00:00
starred.md [red-knot] function parameter types (#14802) 2024-12-06 12:55:56 -08:00
stdlib_typing_aliases.md [red-knot] Basic support for other legacy typing aliases (#14998) 2024-12-17 09:33:15 +00:00
string.md Display Union of Literals as a Literal (#14993) 2025-01-08 00:58:38 +00:00
union.md [red-knot] support typing.Union in type annotations (#14499) 2024-11-20 21:55:33 +00:00
unsupported_special_forms.md [red-knot] Basic support for other legacy typing aliases (#14998) 2024-12-17 09:33:15 +00:00
unsupported_type_qualifiers.md [red-knot] Initial tests for instance attributes (#15474) 2025-01-15 14:43:41 +00:00