Minor cleanup and consistent formatting of the Markdown-based tests. - Removed lots of unnecessary `a`, `b`, `c`, … variables. - Moved test assertions (`# revealed:` comments) closer to the tested object. - Always separate `# revealed` and `# error` comments from the code by two spaces, according to the discussion [here](https://github.com/astral-sh/ruff/pull/13746/files#r1799385758). This trades readability for consistency in some cases. - Fixed some headings
451 B
451 B
Assignment with annotations
Annotation only transparent to local inference
x = 1
x: int
y = x
reveal_type(y) # revealed: Literal[1]
Violates own annotation
x: int = 'foo' # error: [invalid-assignment] "Object of type `Literal["foo"]` is not assignable to `int`"
Violates previous annotation
x: int
x = 'foo' # error: [invalid-assignment] "Object of type `Literal["foo"]` is not assignable to `int`"