Closed alexei closed 6 days ago
You can enable the possibly-undefined error code https://mypy.readthedocs.io/en/stable/error_code_list2.html#warn-about-variables-that-are-defined-only-in-some-execution-paths-possibly-undefined
Thank you, @hauntsaninja
I found an instance where mypy is not behaving the way a developer would expect:
mypy reports on line 13: "error: Cannot determine type of "retval" [has-type]", but not on line 7 as well. I would expect it to treat
retval
as an undefined variable as the condition can also be false - there's no way to tell.Gist URL: https://gist.github.com/mypy-play/33d1f016c63e3c72dcaf1e89256b4af0 Playground URL: https://mypy-play.net/?mypy=latest&python=3.12&gist=33d1f016c63e3c72dcaf1e89256b4af0