← Back to context

Comment by planede

3 years ago

So this is mostly about __subclasshook__. How does this interact with mypy type checking? There must be some tension there too.

edit: I guess I found my answer [1]. That's kind of expected, but it's still ugly.

https://stackoverflow.com/questions/71811960/how-to-use-subc...

Even if someone would like Python to pretend to be statically typed, __subclasshook__ is real (and not even type checking in the traditional sense) while type declarations and their checkers are only quasi-executable documentation.

Personally, I think this is a very good situation: extremely dynamic languages are a worthwhile tool, and the only issue with the pattern matching "exploits" in the article is that boolean operators and non-cached evaluation for subclass checks are not built-in.