Skip to content

Improve from x import error message #118082

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

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

Improve from x import error message #118082

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

While reading new ruff release notes: https://astral.sh/blog/ruff-v0.4.0 I found that it has a new nice parser feature that we can addopt. Before:

>>> from x import
  File "<stdin>", line 1
    from x import
                 ^
SyntaxError: invalid syntax
>>> from . import
  File "<stdin>", line 1
    from . import
                 ^
SyntaxError: invalid syntax
>>> from x import
  File "<stdin>", line 1
    from x import
                 ^
SyntaxError: Expected one or more names after 'import'
>>> from . import
  File "<stdin>", line 1
    from . import
                 ^
SyntaxError: Expected one or more names after 'import'
>>> 

I have a PR ready :)

Linked PRs

@sobolevn sobolevn added type-feature A feature request or enhancement interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Apr 19, 2024
@sobolevn sobolevn self-assigned this Apr 19, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Apr 19, 2024
@sobolevn
Copy link
Member Author

Why ignoring just import?

>>> import
  File "<stdin>", line 1
    import
          ^
SyntaxError: invalid syntax

I will update my PR.

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