-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed as not planned
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
The following return line reports an error although the expression returns the correct type.
To Reproduce
def demo_stddev(self) -> float:
"""Return the standard deviation of the time per iteration (aka SD, σ)."""
values: list[float] = [1.0, 2.0, 3.0, 5.0]
n = len(values)
if n <= 1:
return 0.0
mean: float = sum(values) / n
return (sum((x - mean) ** 2 for x in values) / n) ** 0.5
Expected Behavior
Emit no error
Actual Behavior
The following return line reports an error Returning Any from function declared to return "float"
Additional note
Appending # type: ignore
is not a solution, because this will interfere with pyright:
Pyright correctly accepts the return type and will correctly report an error Unnecessary "# type: ignore" comment
Your Environment
- VSCode
- mypy 1.13.0 (compiled: yes)
- Python 3.12.6
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong