-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: Allowing overload of ClassVar from superclass #2690
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2690 +/- ##
=======================================
Coverage 89.69% 89.70%
=======================================
Files 366 366
Lines 47049 47071 +22
Branches 7139 7140 +1
=======================================
+ Hits 42201 42223 +22
Misses 3745 3745
Partials 1103 1103 ☔ View full report in Codecov by Sentry. |
xdsl/irdl/irdl.py
Outdated
if field_name.isupper() and ( | ||
get_origin(annotations[field_name]) is ClassVar | ||
or ( | ||
isinstance(annotations[field_name], str) | ||
and annotations[field_name].startswith("ClassVar") | ||
) | ||
): | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing as we have this in two places now, could we factor this out to make it easier to see that the two checks are identical? And maybe also make this code denser again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds very reasonable, have factored out the check as suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor nit on factoring out the check. Otherwise LGTM, thanks for the core contribution!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
This is to enhance PR #2687, which allowed uppercase
ClassVar
fields on ops.This PR adds support for the case that an uppercase
ClassVar
is defined (without a value) in a superclass and assigned a value in a subclass. This is confirmed by performing the same check as in the other PR.