Ivan Levkivskyi <levkivs...@gmail.com> added the comment:

> but even then types in the typing could themselves implement 
> `__instancecheck__` and `__subclasscheck__` and retain the old behavior.

It doesn't work that way. `__instancecheck__` and `__subclasscheck__` tweaks 
the behaviour of superclass (i.e. the right argument) in `isinstance()` and 
`issubclass()`. This is how `isinstance([], typing.Iterable)` works, you can't 
use the same to tweak `isinstance(typing.Iterable, type)`.

> Hopefully someone with more insight on this can comment my worries. Perhaps 
> the attribute should also be documented as discussed earlier: 
> https://github.com/python/typing/issues/335

No, it is not safe to use it and will not be documented. You missed the point 
of my previous post, the idea is to add public wrappers in typing that will 
hide `__origin__` (or whatever else) as an implementation detail. Using 
`__origin__` is OK however as a *temporary* measure, if you don't want to use 
`typing_inspect` in the meantime.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34568>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to