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
xdsl: Use type annotations in PyRDL #338
Conversation
1e3ef64
to
86ad534
Compare
Codecov ReportBase: 88.53% // Head: 88.61% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #338 +/- ##
==========================================
+ Coverage 88.53% 88.61% +0.07%
==========================================
Files 65 65
Lines 8017 8054 +37
Branches 1270 1278 +8
==========================================
+ Hits 7098 7137 +39
+ Misses 660 658 -2
Partials 259 259
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Note that this doesn't remove as much PyRight errors as we thought, since the main Pyright errors are from operands and results. |
I changed the names for attribute definitions, since we cannot use |
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.
LGTM!
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.
LGTM!
I feel like an example that now works would be cool, but I guess that is mainly visible in the pyright CI as well as the IDE support.
@@ -448,6 +469,13 @@ def __init__(self, typ: Attribute | type[Attribute] | AttrConstraint): | |||
super().__init__(typ) | |||
|
|||
|
|||
_OpAttrT = TypeVar("_OpAttrT", bound=Attribute) | |||
|
|||
OpAttr: TypeAlias = Annotated[_OpAttrT, IRDLAnnotations.AttributeDefAnnot] |
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.
We need to think about this naming.
- it sounds bad.
- do we want attributes that can only be attached to ops (OpAttr sounds like it).
Maybe AttrAnnotation
, Attribute
, AttributeAnnot
. This is very hard and I feel my names are bad aswell 😅
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.
So the annotations should be private for the users, and are just used for introspection.
We sadly cannot use Attribute
, because this class has to be different than Attribute
.
I went with OpAttr
since we have OpResult
, but yeah that's ugly especially with OptOpAttr
.
It would be nice to get this in as I rely on some of the bug fixes in this PR for Chapter 2 of the tutorial. Would it be ok if I addressed the comments on this PR while Mathieu is on holiday? |
9091e69
to
1bb7cf7
Compare
I think all comments should be addressed now, besides the naming one which no one seems to have a good idea :/ |
I'll let you decide what to do with this PR, but for me I'm fine to merge it now, and maybe think more of better naming for later? |
We have Find/Replace for naming, I think the type names are fine :) |
Yes sure, let's merge it and fix the naming another day. |
This PR updates PyRDL to use type annotations.
This should greatly reduce the amount of PyRight type checking errors.