Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -927,12 +927,12 @@ def _(a: int | None):

Regression test for [#1611](https://github.com/astral-sh/ty/issues/1611).

<!-- blacken-docs:off -->
<!-- fmt:off -->

```py
# error: [invalid-syntax]
# error: [invalid-syntax-in-forward-annotation]
a:'
```

<!-- blacken-docs:on -->
<!-- fmt:on -->
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,14 @@ it having the same AST as the one without the parentheses. Both mypy and Pyright
reveal_type(OnlyParamSpec[(int, str)]().attr) # revealed: (int, str, /) -> None
```

<!-- blacken-docs:off -->
<!-- fmt:off -->

```py
# error: [invalid-syntax]
reveal_type(OnlyParamSpec[]().attr) # revealed: (...) -> None
```

<!-- blacken-docs:on -->
<!-- fmt:on -->

The square brackets can be omitted when `ParamSpec` is the only type variable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def foo1[**P]() -> None:
TODO: This results in a lot of syntax errors mainly because the AST doesn't accept them in this
position. The parser could do a better job in recovering from these errors.

<!-- blacken-docs:off -->
<!-- fmt:off -->

```py
# error: [invalid-syntax]
Expand All @@ -37,7 +37,7 @@ def foo[**P: int]() -> None:
pass
```

<!-- blacken-docs:on -->
<!-- fmt:on -->

## Default

Expand Down Expand Up @@ -255,14 +255,14 @@ it having the same AST as the one without the parentheses. Both mypy and Pyright
reveal_type(OnlyParamSpec[(int, str)]().attr) # revealed: (int, str, /) -> None
```

<!-- blacken-docs:off -->
<!-- fmt:off -->

```py
# error: [invalid-syntax]
reveal_type(OnlyParamSpec[]().attr) # revealed: (...) -> None
```

<!-- blacken-docs:on -->
<!-- fmt:on -->

The square brackets can be omitted when `ParamSpec` is the only type variable

Expand Down
4 changes: 2 additions & 2 deletions crates/ty_python_semantic/resources/mdtest/import/star.md
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ _Z: bool = True

`b.py`:

<!-- blacken-docs:off -->
<!-- fmt:off -->

```py
from a import *, _Y # error: [invalid-syntax]
Expand All @@ -1509,6 +1509,6 @@ from a import *, _Y as fooo # error: [invalid-syntax]
from a import *, *, _Y # error: [invalid-syntax]
```

<!-- blacken-docs:on -->
<!-- fmt:on -->

[python language reference for import statements]: https://docs.python.org/3/reference/simple_stmts.html#the-import-statement
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test(a: f"f-string type annotation", b: b"byte-string-type-annotation"): ...

## Can't suppress syntax errors

<!-- blacken-docs:off -->
<!-- fmt:off -->

```py
# error: [invalid-syntax]
Expand All @@ -84,7 +84,7 @@ def test($): # ty: ignore
pass
```

<!-- blacken-docs:on -->
<!-- fmt:on -->

## Can't suppress `revealed-type` diagnostics

Expand Down Expand Up @@ -127,14 +127,14 @@ a = 10 / 0 # ty: ignore[*-*]

## Trailing whitespace

<!-- blacken-docs:off -->
<!-- fmt:off -->

```py
a = 10 / 0 # ty: ignore[division-by-zero]
# ^^^^^^ trailing whitespace
```

<!-- blacken-docs:on -->
<!-- fmt:on -->

## Missing comma

Expand Down
2 changes: 1 addition & 1 deletion crates/ty_python_semantic/resources/mdtest/t_strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(NB: `black` does not support Python 3.14 at the time of this writing)

<!-- blacken-docs:off -->
<!-- fmt:off -->

```toml
[environment]
Expand Down
6 changes: 3 additions & 3 deletions crates/ty_test/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ impl<'s> Parser<'s> {
const SECTION_CONFIG_SNAPSHOT: &str = "snapshot-diagnostics";
const SECTION_CONFIG_PULLTYPES: &str = "pull-types:skip";
const SECTION_CONFIG_EXPECT_PANIC: &str = "expect-panic";
const HTML_COMMENT_ALLOWLIST: &[&str] = &["blacken-docs:on", "blacken-docs:off"];
const HTML_COMMENT_ALLOWLIST: &[&str] = &["fmt:on", "fmt:off"];
const CODE_BLOCK_END: &[u8] = b"```";
const HTML_COMMENT_END: &[u8] = b"-->";

Expand Down Expand Up @@ -2066,13 +2066,13 @@ mod tests {
let source = dedent(
"
# Some header
<!-- blacken-docs:off -->
<!-- fmt:off -->

```py
x = 1
```

<!-- blacken-docs:on -->
<!-- fmt:on -->
",
);
let parse_result = super::parse("file.md", &source);
Expand Down
Loading