-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type guard in list comprehension with assignment expression does not constrain type #8236
Labels
topic-pep-572
PEP 572 (walrus operator)
Comments
This might be the same bug as #7316. |
hauntsaninja
pushed a commit
to hauntsaninja/mypy
that referenced
this issue
Jan 9, 2020
In theory, this draft commit fixes python#8236 However, it looks like the ComparisonExpr part of find_isinstance_check_helper was rewritten today morning in python#8151. It looks like it's not super easy to merge: `is_valid_target` gets in the way and I'm a lot less sure about the change. I'm also not fully sure about the implications of making AssignmentExpr into mypy.literals, but seems like it's what we'd want. I also don't really like the way I've branched for AssignmentExpr, it's pretty unsatisfactory. Well, work in progress!
hauntsaninja
pushed a commit
to hauntsaninja/mypy
that referenced
this issue
Jan 9, 2020
In theory, this draft commit fixes python#8236 However, it looks like the ComparisonExpr part of find_isinstance_check_helper was rewritten today morning in python#8151. It looks like it's not super easy to merge: `is_valid_target` gets in the way and I'm a lot less sure about the change. I'm also not fully sure about the implications of making AssignmentExpr into mypy.literals, but seems like it's what we'd want. I also don't really like the way I've branched for AssignmentExpr, it's pretty unsatisfactory. Well, work in progress!
Closing in favor its duplicate #8447 which is about to be fixed anyway |
@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. |
@hauntsaninja Sorry, this project wasn't. I appreciate the ask, though. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the first function, mypy interprets the
match
variable asOptional[Match[str]]
and flags the use of the possibly-None
object. In the second function,match
under theif
statement is consideredMatch[str]
.Since both statements guard the
match
variable against beingNone
, both uses should be of typeMatch[str]
.Do you see the same issue after installing mypy from Git master? Don't know how
The text was updated successfully, but these errors were encountered: