Skip to content

Redefinition from None not an error -- a bug? #8158

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
iutlu opened this issue Dec 17, 2019 · 1 comment
Closed

Redefinition from None not an error -- a bug? #8158

iutlu opened this issue Dec 17, 2019 · 1 comment

Comments

@iutlu
Copy link

iutlu commented Dec 17, 2019

The following code

def test(param: Optional[int]) -> List[str]:
    ret = None  # Revealed type is 'None'
    if param is not None:
        ret = []
        ret.append('')  # Revealed type is 'builtins.list[builtins.str]'
    return ret

does not raise any errors, which looks like a bug since the return value is not necessarily a List[str] -- tested with mypy 0.750, Python 3.7.

mypy.ini:

no_implicit_optional = True
@ilevkivskyi
Copy link
Member

I think this is a duplicate of #4088 (which itself btw may be also related to #5423).

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

No branches or pull requests

2 participants