Skip to content

Comments

[syntax-errors] type statements before Python 3.12#16478

Merged
ntBre merged 7 commits intomainfrom
brent/syn-type-stmt
Mar 4, 2025
Merged

[syntax-errors] type statements before Python 3.12#16478
ntBre merged 7 commits intomainfrom
brent/syn-type-stmt

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
@github-actions
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.

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