Skip to content

False negative when using the power (**) operator #7765

Closed
@nikola-benes

Description

@nikola-benes

When checking the following function with mypy 0.730 (Python version 3.7.4):

def foo(x: int) -> str:
   return 2 ** x

mypy reports no errors:

Success: no issues found in 1 source file

With the --strict option turned on, mypy reports:

foo.py:2: error: Returning Any from function declared to return "str"

The expected output would be something like

foo.py:2: error: Incompatible return value type (got "int", expected "str")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions