mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 22:55:08 +00:00
[red-knot] Enforce specifying paths for mdtest code blocks in a separate preceding line (#15890)
## Summary Resolves #15695, rework of #15704. This change modifies the Mdtests framework so that: * Paths must now be specified in a separate preceding line: `````markdown `a.py`: ```py x = 1 ``` ````` If the path of a file conflicts with its `lang`, an error will be thrown. * Configs are no longer accepted. The pattern still take them into account, however, to avoid "Unterminated code block" errors. * Unnamed files are now assigned unique, `lang`-respecting paths automatically. Additionally, all legacy usages have been updated. ## Test Plan Unit tests and Markdown tests. --------- Co-authored-by: Carl Meyer <carl@astral.sh>
This commit is contained in:
parent
0529ad67d7
commit
11cfe2ea8a
35 changed files with 967 additions and 286 deletions
|
@ -25,7 +25,9 @@ x = "foo" # error: [invalid-assignment] "Object of type `Literal["foo"]` is not
|
|||
|
||||
## Tuple annotations are understood
|
||||
|
||||
```py path=module.py
|
||||
`module.py`:
|
||||
|
||||
```py
|
||||
from typing_extensions import Unpack
|
||||
|
||||
a: tuple[()] = ()
|
||||
|
@ -40,7 +42,9 @@ i: tuple[str | int, str | int] = (42, 42)
|
|||
j: tuple[str | int] = (42,)
|
||||
```
|
||||
|
||||
```py path=script.py
|
||||
`script.py`:
|
||||
|
||||
```py
|
||||
from module import a, b, c, d, e, f, g, h, i, j
|
||||
|
||||
reveal_type(a) # revealed: tuple[()]
|
||||
|
@ -114,7 +118,7 @@ reveal_type(x) # revealed: Foo
|
|||
|
||||
## Annotations in stub files are deferred
|
||||
|
||||
```pyi path=main.pyi
|
||||
```pyi
|
||||
x: Foo
|
||||
|
||||
class Foo: ...
|
||||
|
@ -125,7 +129,7 @@ reveal_type(x) # revealed: Foo
|
|||
|
||||
## Annotated assignments in stub files are inferred correctly
|
||||
|
||||
```pyi path=main.pyi
|
||||
```pyi
|
||||
x: int = 1
|
||||
reveal_type(x) # revealed: Literal[1]
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue