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

Add support for tuple values on except clauses by pdmccormick · Pull Request #1610 · python/mypy · GitHub

Repository navigation

Add support for tuple values on except clauses - #1610

Merged
gnprice merged 6 commits into
python:masterfrom
pdmccormick:master
Jun 3, 2016
Merged

gnprice merged 6 commits into
python:masterfrom
pdmccormick:master

Conversation

Copy link
Copy Markdown
Contributor

Fixes issue #1590.

Comment thread mypy/test/data/check-statements.test Outdated
exs3 = (E2, E3)
try: pass
except exs3 as e3:
reveal_type(e3) # E: Revealed type is '__main__.E1'

Copy link
Copy Markdown
Collaborator

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

Huh, this is puzzling -- do you understand why it ends up being E1?

Copy link
Copy Markdown
Contributor 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

E1 is the nearest common ancestor to E2 and E3, so it is the most specific type that generalizes both.

Comment thread mypy/checker.py Outdated
self.fail('Unsupported exception', n)
return AnyType()

def check_for_function_like_exception_type(self, type: Type, context: Context) -> Type:

Copy link
Copy Markdown
Collaborator

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

Because this can return None and not only an actual Type, let's annotate as Optional[Type]. PEP 484 specifies that types don't implicitly contain None; we don't quite yet implement that properly in mypy, so we don't catch this, but there's an active PR for it (#1562) and we will soon.

gnprice merged commit e2ab99f into python:master Jun 3, 2016

gnprice commented Jun 3, 2016

Copy link
Copy Markdown
Collaborator

Thanks @pdmccormick for the fix! I also appreciate the negative diffstat on application code, and the positive diffstat on test code. :-)

pdmccormick added a commit to pdmccormick/mypy that referenced this pull request Jun 3, 2016
gnprice pushed a commit that referenced this pull request Jun 3, 2016
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.

2 participants


Back | FazBrowse Home | New Git URL