-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
help wantedContributions especially welcomeContributions especially welcometyMulti-file analysis & type inferenceMulti-file analysis & type inference
Description
The task is to raise a invalid-type-form error that states "Invalid type expression" for the following three literal types:
ruff/crates/red_knot_python_semantic/src/types/infer.rs
Lines 5661 to 5666 in 44aec36
| // Other literals do not have meaningful values in the annotation expression context. | |
| // However, we will we want to handle these differently when working with special forms, | |
| // since (e.g.) `123` is not valid in an annotation expression but `Literal[123]` is. | |
| ast::Expr::BytesLiteral(_literal) => todo_type!("bytes literal in type expression"), | |
| ast::Expr::NumberLiteral(_literal) => todo_type!("number literal in type expression"), | |
| ast::Expr::BooleanLiteral(_literal) => todo_type!("boolean literal in type expression"), |
The reason is that those literal types are handled appropriately in the relevant context like typing.Literal, typing.Annotated.
This will also require fixing / updating the tests w.r.t. this change.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedContributions especially welcomeContributions especially welcometyMulti-file analysis & type inferenceMulti-file analysis & type inference