-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[syntax-errors] type
statements before Python 3.12
#16478
Conversation
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
|
@@ -449,6 +449,7 @@ pub enum UnsupportedSyntaxErrorKind { | |||
Match, | |||
Walrus, | |||
ExceptStar, | |||
TypeStmt, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use type alias instead of type statement? I would find this more approachable as a user, unless the term is ambiguous.
TypeStmt, | |
TypeAlias, |
https://docs.python.org/3/library/typing.html#type-aliases
If not TypeAlias
, then rename to TypeStatement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pyright calls them "type alias statements," which I think sounds good for the user-facing message. For the variant name, I don't have strong feelings either way. They do call it a type_stmt
in the Python reference, so I might lean toward TypeStatement
if you prefer that to Stmt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just call it TypeAliasStatement
, I see that's what we call the parser function now.
Summary
Another simple one, just detect standalone
type
statements. I limited the diagnostic totype
itself like pyright. That probably makes the most sense for more complicated examples.Test Plan
Inline tests.