Skip to content
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

Merged
merged 7 commits into from
Mar 4, 2025
Merged

Conversation

ntBre
Copy link
Contributor

@ntBre ntBre commented Mar 3, 2025

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.

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
@ntBre ntBre added parser Related to the parser preview Related to preview mode features labels Mar 3, 2025
Copy link
Contributor

github-actions bot commented Mar 3, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@@ -449,6 +449,7 @@ pub enum UnsupportedSyntaxErrorKind {
Match,
Walrus,
ExceptStar,
TypeStmt,
Copy link
Member

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.

Suggested change
TypeStmt,
TypeAlias,

https://docs.python.org/3/library/typing.html#type-aliases

If not TypeAlias, then rename to TypeStatement

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@ntBre ntBre enabled auto-merge (squash) March 4, 2025 17:18
@ntBre ntBre merged commit 32c66ec into main Mar 4, 2025
20 checks passed
@ntBre ntBre deleted the brent/syn-type-stmt branch March 4, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Related to the parser preview Related to preview mode features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants