Skip to content

Type issue not found in function call #8434

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
maxnoe opened this issue Feb 24, 2020 · 3 comments
Closed

Type issue not found in function call #8434

maxnoe opened this issue Feb 24, 2020 · 3 comments

Comments

@maxnoe
Copy link

maxnoe commented Feb 24, 2020

Running mypy on this small code example:

def build_greeting(name: str = 'World') -> str:
    return f'Hello {name}!'


def greet(name='World'):
    print(build_greeting(name))


if __name__ == '__main__':
    greet('foo')
    greet(4)

results in it reporting "no issues". Although greet and thus build_greeting are called with an integer.

@emmatyping
Copy link
Member

Hi, since greet isn't annotated it isn't checked, please see https://mypy.readthedocs.io/en/stable/common_issues.html#no-errors-reported-for-obviously-wrong-code

@maxnoe
Copy link
Author

maxnoe commented Feb 25, 2020

This also shows no issue:

from typing import Any


def build_greeting(name: str = 'World') -> str:
    return f'Hello {name}!'


def greet(name: Any = 'World') -> None:
    print(build_greeting(name))


if __name__ == '__main__':
    greet(4)

So transitive problems don't seem to be checked.

@emmatyping
Copy link
Member

Mypy doesn't really do interprocedural analysis like that.

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