Replies: 1 comment
-
I think this is a bug in the latest mypy. (Which means this would be better as an issue on the mypy repo.) The You can work around it by telling mypy to treat your narrowed found: Foo = foo
my_list.append(found) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wasn't sure if this was an actual bug, so posing a question here first. This code is just an example - it filters using an
isinstance
call to try to find objects that fit the profile of bothFoo
andBar
:This code does not fail on Mypy 1.14.1:
https://mypy-play.net/?mypy=1.14.1&python=3.12&gist=7b5be66ab0fb3f04d15a99317ef21a7d
But it does fail on Mypy 1.15:
https://mypy-play.net/?mypy=1.15.0&python=3.12&gist=7b5be66ab0fb3f04d15a99317ef21a7d
My question is simple - is this a bug/regression, or this code invalid? And if so, why?
Beta Was this translation helpful? Give feedback.
All reactions