Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Type issue not found in function call #8434

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
Collaborator

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
Collaborator

Mypy doesn't really do interprocedural analysis like that.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants