fix: better handling of parametrized types#991
Merged
JohannesMessner merged 8 commits intofeat-rewrite-v2from Jan 12, 2023
Merged
fix: better handling of parametrized types#991JohannesMessner merged 8 commits intofeat-rewrite-v2from
JohannesMessner merged 8 commits intofeat-rewrite-v2from
Conversation
Signed-off-by: Johannes Messner <[email protected]>
Member
Author
|
I believe there is a deeper issue at hand that we better solve. So let's not merge this for now. |
samsja
reviewed
Jan 5, 2023
Signed-off-by: Johannes Messner <[email protected]>
Signed-off-by: Johannes Messner <[email protected]>
Signed-off-by: Johannes Messner <[email protected]>
Signed-off-by: Johannes Messner <[email protected]>
Signed-off-by: Johannes Messner <[email protected]>
Signed-off-by: Johannes Messner <[email protected]>
samsja
reviewed
Jan 12, 2023
| ShapeT = TypeVar('ShapeT') | ||
|
|
||
|
|
||
| class _ParametrizedMeta(type): |
Member
There was a problem hiding this comment.
not sure that type is needed here
Member
Author
There was a problem hiding this comment.
Not sure if it is strictly needed bc in the end the "final" metaclass will only inherit from this one, but I think if we wanted to use _ParametrizedMeta directly as a metaclass we would need it. So I think it is good practice for all metclasses to do it
Signed-off-by: Johannes Messner <[email protected]>
|
📝 Docs are deployed on https://ft-fix-bad-torch-subclassing--jina-docs.netlify.app 🎉 |
samsja
approved these changes
Jan 12, 2023
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Johannes Messner [email protected]
Goals:
fix #988
This fixes the issue by making sure that parametrized types that are equivalent are treated as equal.
For example, the code snippet:
creates two different but identical classes.
This PR makes it such that
issubclassandisinstancechecks treat these two classes as the same class.This fixes a bunch of downstream bugs, such as #998 and other cases that can be seen in the tests that are added by this PR.