You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type guard in list comprehension with assignment expression does not constrain type #8236
In the first function, mypy interprets the match variable as Optional[Match[str]] and flags the use of the possibly-None object. In the second function, match under the if statement is considered Match[str].
What is the behavior/output you expect?
Since both statements guard the match variable against being None, both uses should be of type Match[str].
What are the versions of mypy and Python you are using? mypy 0.761, Python 3.8
Do you see the same issue after installing mypy from Git master? Don't know how
What are the mypy flags you are using? (For example --strict-optional) Nothing relevant
Activity
fluggo commentedon Jan 6, 2020
This might be the same bug as #7316.
Narrow types for walrus in identity comparison
Narrow types for walrus in identity comparison
msullivan commentedon Feb 28, 2020
Closing in favor its duplicate #8447 which is about to be fixed anyway
hauntsaninja commentedon Sep 27, 2020
@fluggo I was wondering if the code you're working on is open source? My interest is in adding projects to https://github.com/hauntsaninja/mypy_primer that use newer Python features.
fluggo commentedon Sep 28, 2020
@hauntsaninja Sorry, this project wasn't. I appreciate the ask, though.