Show more precise messages in invalid type expressions#16850
Show more precise messages in invalid type expressions#16850AlexWaygood merged 10 commits intoastral-sh:mainfrom
Conversation
|
Im not fully sure where to put tests for the currently unsupported special forms and type qualifiers |
|
maybe these files?
|
|
Yeah, i thought that, but we does providing error messages not imply that we are supporting them partially? |
|
True. We'll need comprehensive test suites covering each special form eventually, so you can create new files for each now if you like! But equally, I don't think it matters too much right now; I'd be inclined to just adjust the prose a little bit in those files saying that we don't fully support them, but we do detect some invalid uses when they appear in type expressions. |
|
Okay, will do that then, thanks |
|
Tests failing because def _(
a: Final
) -> None: ...raises no error Ill change it to Final | int. @AlexWaygood why does this happen exactly? |
That's because we currently only validate that parameter annotations are valid annotation expressions. Bare You can take a look at the typing spec page here for an explanation of the difference between the two concepts: https://typing.python.org/en/latest/spec/annotations.html#type-and-annotation-expressions. Now, is |
|
|
Okay understood. What function infers the type of parameter annotations? |
|
crates/red_knot_python_semantic/resources/mdtest/annotations/unsupported_special_forms.md
Outdated
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/annotations/unsupported_special_forms.md
Outdated
Show resolved
Hide resolved
…nsupported_special_forms.md Co-authored-by: Alex Waygood <[email protected]>
…nsupported_special_forms.md Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
* main: (26 commits) Use the common `OperatorPrecedence` for the parser (#16747) [red-knot] Check subtype relation between callable types (#16804) [red-knot] Check whether two callable types are equivalent (#16698) [red-knot] Ban most `Type::Instance` types in type expressions (#16872) Special-case value-expression inference of special form subscriptions (#16877) [syntax-errors] Fix star annotation before Python 3.11 (#16878) Recognize `SyntaxError:` as an error code for ecosystem checks (#16879) [red-knot] add test cases result in false positive errors (#16856) Bump 0.11.1 (#16871) Allow discovery of venv in VIRTUAL_ENV env variable (#16853) Split git pathspecs in change determination onto separate lines (#16869) Use the correct base commit for change determination (#16857) Separate `BitXorOr` into `BitXor` and `BitOr` precedence (#16844) Server: Allow `FixAll` action in presence of version-specific syntax errors (#16848) [`refurb`] Fix starred expressions fix (`FURB161`) (#16550) [`flake8-executable`] Add pytest and uv run to help message for `shebang-missing-python` (`EXE003`) (#16855) Show more precise messages in invalid type expressions (#16850) [`flake8-executables`] Allow `uv run` in shebang line for `shebang-missing-python` (`EXE003`) (#16849) Add `--exit-non-zero-on-format` (#16009) [red-knot] Ban list literals in most contexts in type expressions (#16847) ...
Summary
Some error messages are not very specific and could be improved
Test Plan
Not yet sure where to put some tests, but will just test invalid type expressions