Skip to content

Should Mypy warn about potential invalid arguments to max? #4051

Description

@willmcgugan

I was surprised that Mypy didn't flag an issue where I was calling max with an int and a None, which throws a TypeError at runtime.

For example, in the following code, should I not expect Mypy to warn that top is potentially None, which wouldn't work with max ?

fromtypingimportOptionaltop: Optional[int] =Noneprint(max(5, top))

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: false negativeType checkers do not report an error, but should

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions