Skip to content

fastparse: improve error reporting for f-string syntax errors #8970

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

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fastparse: improve error reporting for f-string syntax errors
  • Loading branch information
hauntsaninja committed Jun 8, 2020
commit d38104e208e2c6c71b122f8288f282175ff89543
5 changes: 5 additions & 0 deletions mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ def parse(source: Union[str, bytes],
tree.path = fnam
tree.is_stub = is_stub_file
except SyntaxError as e:
if sys.version_info < (3, 9) and e.filename == "<fstring>":
# In Python 3.8 and earlier, syntax errors in f-strings have lineno relative to the
# start of the f-string. This would be misleading, as mypy will report the error as the
# lineno within the file.
e.lineno = None
errors.report(e.lineno if e.lineno is not None else -1, e.offset, e.msg, blocker=True,
code=codes.SYNTAX)
tree = MypyFile([], [], False, {})
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy