What precisely is required for isinstance
checks to succeed against data-Protocols
?
#1941
Unanswered
randolf-scholz
asked this question in
Q&A
Replies: 2 comments 1 reply
-
So, the issue seems to be that torch does not write an entry into |
Beta Was this translation helpful? Give feedback.
0 replies
-
The implementation of runtime-checkable protocols indeed uses |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The following example fails at runtime:
It seems the culprit is a combination of
torch.nn.Module
doing stuff with__getattr__
/__setattr_
which makesinspect.getattr_static
fail. However, what surprises me is that both__annotations__
and__static_attributes__
are seemingly ignored. Is this intended or just underspecified?I am trying to replicate this from scratch, but even with some non-static indirection it still works, haven't figured out what exactly makes torch break the isinstance check here.
Beta Was this translation helpful? Give feedback.
All reactions