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

Improve class A[]: ... syntax error message #118090

Closed
sobolevn opened this issue Apr 19, 2024 · 1 comment
Closed

Improve class A[]: ... syntax error message #118090

sobolevn opened this issue Apr 19, 2024 · 1 comment
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@sobolevn
Copy link
Member

sobolevn commented Apr 19, 2024

Feature or enhancement

Right now it will generate this default error:

>>> class A[]: ...
  File "<stdin>", line 1
    class A[]: ...
            ^
SyntaxError: invalid syntax
>>> def some[](arg: int) -> None: ...
  File "<stdin>", line 1
    def some[](arg: int) -> None: ...
            ^
SyntaxError: expected '('
>>> type Alias[] = int
  File "<stdin>", line 1
    type Alias[] = int
               ^
SyntaxError: invalid syntax

I propose to change it to:

>>> class A[]:
  File "<stdin>", line 1
    class A[]:
            ^
SyntaxError: At least one type variable definition is expected
>>> def some[](arg: int) -> None: ...
  File "<stdin>", line 1
    def some[](arg: int) -> None: ...
             ^
SyntaxError: At least one type variable definition is expected

>>> type Alias[] = int
  File "<stdin>", line 1
    type Alias[] = int
               ^
SyntaxError: At least one type variable definition is expected

I have a PR ready.

Linked PRs

@wookie184
Copy link
Contributor

It looks like this was fixed, can this be closed @sobolevn?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants