-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dcreager/alist-type
* main: [red-knot] Switch to a handwritten parser for mdtest error assertions (#16422) [red-knot] Disallow more invalid type expressions (#16427) Bump version to Ruff 0.9.9 (#16434) Check `LinterSettings::preview` for version-related syntax errors (#16429) Avoid caching files with unsupported syntax errors (#16425) Prioritize "bug" label for changelog sections (#16433) [`flake8-copyright`] Add links to applicable options (`CPY001`) (#16421) Fix string-length limit in documentation for PYI054 (#16432) Show version-related syntax errors in the playground (#16419) Allow passing `ParseOptions` to inline tests (#16357) Bump version to 0.9.8 (#16414) [red-knot] Ignore surrounding whitespace when looking for `<!-- snapshot-diagnostics -->` directives in mdtests (#16380) Notify users for invalid client settings (#16361) Avoid indexing the project if `configurationPreference` is `editorOnly` (#16381)
- Loading branch information
Showing
34 changed files
with
1,247 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
crates/red_knot_python_semantic/resources/mdtest/annotations/invalid.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Tests for invalid types in type expressions | ||
|
||
## Invalid types are rejected | ||
|
||
Many types are illegal in the context of a type expression: | ||
|
||
```py | ||
import typing | ||
from knot_extensions import AlwaysTruthy, AlwaysFalsy | ||
from typing_extensions import Literal, Never | ||
|
||
def _( | ||
a: type[int], | ||
b: AlwaysTruthy, | ||
c: AlwaysFalsy, | ||
d: Literal[True], | ||
e: Literal["bar"], | ||
f: Literal[b"foo"], | ||
g: tuple[int, str], | ||
h: Never, | ||
): | ||
def foo(): ... | ||
def invalid( | ||
i: a, # error: [invalid-type-form] "Variable of type `type[int]` is not allowed in a type expression" | ||
j: b, # error: [invalid-type-form] | ||
k: c, # error: [invalid-type-form] | ||
l: d, # error: [invalid-type-form] | ||
m: e, # error: [invalid-type-form] | ||
n: f, # error: [invalid-type-form] | ||
o: g, # error: [invalid-type-form] | ||
p: h, # error: [invalid-type-form] | ||
q: typing, # error: [invalid-type-form] | ||
r: foo, # error: [invalid-type-form] | ||
): | ||
reveal_type(i) # revealed: Unknown | ||
reveal_type(j) # revealed: Unknown | ||
reveal_type(k) # revealed: Unknown | ||
reveal_type(l) # revealed: Unknown | ||
reveal_type(m) # revealed: Unknown | ||
reveal_type(n) # revealed: Unknown | ||
reveal_type(o) # revealed: Unknown | ||
reveal_type(p) # revealed: Unknown | ||
reveal_type(q) # revealed: Unknown | ||
reveal_type(r) # revealed: Unknown | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.