Should variance inference ignore underscore-prefixed attributes?

My personal opinion is that soundness with respect to contravariance is in practice “best effort” in Python, and that’s probably a reasonable tradeoff for usability. While the type systems enthusiast in me would love to see a truly sound type system applied to Python, on the balance I’m mostly just happy to see more and more people enjoy the benefits of a mostly-sound system.

That said, if there is a building consensus that type checkers should be strict about contravariance of attributes, then I’m happy to see it. We might also reconsider unsound contravariant Self types in that case.

1 Like