[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
|
| Match, | ||
| Walrus, | ||
| ExceptStar, | ||
| TypeStmt, |
There was a problem hiding this comment.
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, |
If not TypeAlias, then rename to TypeStatement
There was a problem hiding this comment.
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.
I'll just call it TypeAliasStatement, I see that's what we call the parser function now.
Summary
Another simple one, just detect standalone
typestatements. I limited the diagnostic totypeitself like pyright. That probably makes the most sense for more complicated examples.Test Plan
Inline tests.