FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Gracefully handle invalid type comments in the fast parser by ddfisher · Pull Request #1600 · python/mypy · GitHub

Repository navigation

Gracefully handle invalid type comments in the fast parser - #1600

Merged
JukkaL merged 4 commits into
python:masterfrom
ddfisher:PR/type-comment-errors
Jun 3, 2016
Merged

JukkaL merged 4 commits into
python:masterfrom
ddfisher:PR/type-comment-errors

Conversation

ddfisher commented Jun 1, 2016

Copy link
Copy Markdown
Collaborator

Gives errors with the appropriate line number (instead of unhelpful stack traces) on syntax errors or invalid AST nodes in type comments. E.g.:

syntax error: x = None # type: a : b
invalid AST node: x = None # type: a + b

gvanrossum commented Jun 1, 2016 via email

Copy link
Copy Markdown
Member

ddfisher commented Jun 2, 2016

Copy link
Copy Markdown
Collaborator Author

Fixed lint failures (and missing annotation).

Comment thread mypy/fastparse.py Outdated
except SyntaxError as e:
if errors:
errors.set_file('<input>' if fnam is None else fnam)
errors.report(e.lineno, e.msg) # type: ignore

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Remind me what we're ignoring here again?

ddfisher Jun 2, 2016 •
edited
Loading

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm not sure what we were ignoring here before, because it works without it... except when I combine the except clauses. It looks like then it's taking the join of the two exceptions as the type of e (instead of the Union) and gives me:

mypy/fastparse.py:73: error: "Exception" has no attribute "lineno"
mypy/fastparse.py:73: error: "Exception" has no attribute "msg"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Perhaps related to #1610 (which hasn't been merged yet)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yep! That PR (after it's fixed up a bit more) should fix this.

Copy link
Copy Markdown
Member

Looks okay, but I'll leave it up to @JukkaL to decide whether to merge this before or after the 0.4.2 release.

ddfisher force-pushed the PR/type-comment-errors branch from 5a5f8b0 to 57e2b02 Compare June 3, 2016 01:00

ddfisher commented Jun 3, 2016

Copy link
Copy Markdown
Collaborator Author

Rebase on master and remove now-unnecessary # type: ignore

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL