# Problems with TypeIs

**URL:** <https://discuss.python.org/t/problems-with-typeis/55410>\
**Category:** Typing\
**Tags:** typing\
**Created:** [June 10, 2024, 5:46pm UTC](https://discuss.python.org/t/problems-with-typeis/55410 "2024-06-10T17:46:45Z")\
**Posts on this page:** 1\
**Showing post:** 44

<div class="post-metadata">

**Author:** ![mikeshardmind](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mikeshardmind/32/14381_2.png) [@mikeshardmind](https://discuss.python.org/u/mikeshardmind)\
**Post date:** [July 20, 2024, 3:37pm UTC](https://discuss.python.org/t/problems-with-typeis/55410/44 "2024-07-20T15:37:32Z")

</div>

I can’t think of a way to make this work in python the way you’re describing it without going against this:

> [@Revisiting variance](https://discuss.python.org/t/revisiting-variance/58032/52):
>
> Also, it is a goal of the Python typing specification that it actually describes the behavior of Python type checkers, so that it is useful for both type checker implementers and type system users, not that it describes an impractical extreme which no type checker with actual users is willing to implement and few users want to actually use. So there will always be natural push and pull between the type specification and the practical realities faced by type checkers, and that’s good; it makes the type checkers better (and more similar in their behavior), and it makes the type spec more useful.

It would create far more false positives to not reduce isinstance in a case like this than just flagging potentially suspect TypeIs functions, or even just documenting the current reality here.

I’m willing to accept that there’s probably a way to do this, but I think it’s actually a less useful formulation that makes assumptions that are going to be harder to prove, and result in worse inference.

I think for now documenting this as an unsafe construct and when it would be unsafe is very reasonable, it doesn’t necessarily need to be a type checker error, but users should be able to discover why something may not behave how they thought it would.

---

_[View the full topic](https://discuss.python.org/t/problems-with-typeis/55410)._
