mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-28 15:34:19 +00:00
[syntax-errors] type
alias statements before Python 3.12 (#16478)
Summary -- Another simple one, just detect standalone `type` statements. I limited the diagnostic to `type` itself like [pyright]. That probably makes the most sense for more complicated examples. Test Plan -- Inline tests. [pyright]: https://pyright-play.net/?pythonVersion=3.8&strict=true&code=C4TwDgpgBAHlC8UCWA7YQ
This commit is contained in:
parent
087d92cbf4
commit
32c66ec4b7
6 changed files with 98 additions and 0 deletions
|
@ -449,6 +449,7 @@ pub enum UnsupportedSyntaxErrorKind {
|
|||
Match,
|
||||
Walrus,
|
||||
ExceptStar,
|
||||
TypeAliasStatement,
|
||||
TypeParamDefault,
|
||||
}
|
||||
|
||||
|
@ -458,6 +459,7 @@ impl Display for UnsupportedSyntaxError {
|
|||
UnsupportedSyntaxErrorKind::Match => "Cannot use `match` statement",
|
||||
UnsupportedSyntaxErrorKind::Walrus => "Cannot use named assignment expression (`:=`)",
|
||||
UnsupportedSyntaxErrorKind::ExceptStar => "Cannot use `except*`",
|
||||
UnsupportedSyntaxErrorKind::TypeAliasStatement => "Cannot use `type` alias statement",
|
||||
UnsupportedSyntaxErrorKind::TypeParamDefault => {
|
||||
"Cannot set default type for a type parameter"
|
||||
}
|
||||
|
@ -478,6 +480,7 @@ impl UnsupportedSyntaxErrorKind {
|
|||
UnsupportedSyntaxErrorKind::Match => PythonVersion::PY310,
|
||||
UnsupportedSyntaxErrorKind::Walrus => PythonVersion::PY38,
|
||||
UnsupportedSyntaxErrorKind::ExceptStar => PythonVersion::PY311,
|
||||
UnsupportedSyntaxErrorKind::TypeAliasStatement => PythonVersion::PY312,
|
||||
UnsupportedSyntaxErrorKind::TypeParamDefault => PythonVersion::PY313,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue