Message324680
> 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. |
|
Date |
User |
Action |
Args |
2018-09-06 10:01:32 | levkivskyi | set | recipients:
+ levkivskyi, gvanrossum, pekka.klarck |
2018-09-06 10:01:32 | levkivskyi | set | messageid: <1536228092.68.0.56676864532.issue34568@psf.upfronthosting.co.za> |
2018-09-06 10:01:32 | levkivskyi | link | issue34568 messages |
2018-09-06 10:01:32 | levkivskyi | create | |
|