Skip to content

Conversation

@guilhermeleobas
Copy link
Collaborator

@guilhermeleobas guilhermeleobas added the module: typing Related to mypy type annotations label Jul 29, 2020
@guilhermeleobas guilhermeleobas self-assigned this Jul 29, 2020
@dr-ci
Copy link

dr-ci bot commented Jul 29, 2020

💊 CI failures summary and remediations

As of commit 0cf851e (more details on the Dr. CI page):


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-CircleCI failure(s)

ci.pytorch.org: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 19 times.

@rgommers rgommers self-requested a review July 30, 2020 14:57
Copy link
Collaborator

@hameerabbasi hameerabbasi left a comment

Choose a reason for hiding this comment

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

One minor, optional comment.

frame = inspect.currentframe()
i = 0
while i < frames_up + 1:
assert frame is not None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this not work if you put the assert on the line right below inspect.currentframe()? (it wouldn't surprise me if not, mypy is fragile with this kind of type narrowing)

Technically assert's are used for asserting things that must be true. In this case that is the case (because the reason for None is the below), so the change is correct - just unfortunate the same assert must be used twice and inside a for-loop.

CPython implementation detail: This function relies on Python stack frame support in the interpreter, which isn’t guaranteed to exist in all implementations of Python. If running in an implementation without Python stack frame support this function returns None.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, unfortunately it doesn't work. If I move the assertion to the line below current_frame = inspect.currentframe(), mypy raises an error.

Copy link
Collaborator

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @guilhermeleobas

@rgommers rgommers requested review from ezyang and malfet July 30, 2020 22:13
@ezyang
Copy link
Contributor

ezyang commented Jul 31, 2020

Good stuff. Do you want to handle the CR comments before I merge?

@guilhermeleobas
Copy link
Collaborator Author

Good stuff. Do you want to handle the CR comments before I merge?

Yes, I will address them later today.

@rgommers
Copy link
Collaborator

rgommers commented Aug 2, 2020

Okay all comments addressed, this should be good to land.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@ezyang merged this pull request in 0c48aa1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: typing Related to mypy type annotations open source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants