Skip to content

Invalid type error for deferred function #2299

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
JukkaL opened this issue Oct 21, 2016 · 1 comment
Closed

Invalid type error for deferred function #2299

JukkaL opened this issue Oct 21, 2016 · 1 comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 21, 2016

Mypy complains about the following program because of deferred type checking:

from typing import Union

def f(a: Union[int, str]) -> None:
    x
    a = x
    a + 1   # Error

x = 1 + 1

If x = 1 + 1 is before the function definition there is no error.

This was originally reported by @ecprice: #1748 (comment). There's additional discussion in the linked PR.

@JukkaL JukkaL added the bug mypy got something wrong label Oct 21, 2016
@gvanrossum gvanrossum added this to the 0.5 milestone Oct 27, 2016
@gvanrossum gvanrossum removed this from the 0.5 milestone Mar 29, 2017
@JukkaL JukkaL added the false-positive mypy gave an error on correct code label May 18, 2018
@ilevkivskyi
Copy link
Member

This works correctly on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal
Projects
None yet
Development

No branches or pull requests

3 participants