Follow

Another puzzler; apparently `mypy` doesn't know how to do type narrowing when you do an early return like this:

mypy-play.net/?mypy=latest&pyt

@pganssle I wonder if that has to do with subclasses? Like if you extended str in a class FancyStr and passed that in, your function is expecting FancyStr to be returned back. But you're only returning str, not FancyStr.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.