-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder
Description
Bug Report
I found a weird issue related to redundant-expr
that only happens when the code is defined as a lambda. The same code works fine when defined inside a regular function.
To Reproduce
from typing import Any
import pandas as pd
lambda val: {} if pd.isna(val) else val
def func(val: Any) -> Any:
return {} if pd.isna(val) else val
Expected Behavior
None of the pd.isna
calls are flagged as redundant
Actual Behavior
test_mypy.py:5: error: If condition is always false [redundant-expr]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: mypy 1.15.0 (compiled: yes)
- Mypy command-line flags: mypy --enable-error-code redundant-expr test_mypy.py
- Mypy configuration options from
mypy.ini
(and other config files): - Python version used: 3.12.9
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder