Content-Length: 283439 | pFad | https://github.com/python/cpython/issues/118090

89 Improve `class A[]: ...` syntax error message · Issue #118090 · python/cpython · GitHub
Skip to content

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

@sobolevn

Description

@sobolevn

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

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/118090

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy