-
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: (assembly-format) omit default attributes/properties from attr-dict directive #3783
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3783 +/- ##
==========================================
- Coverage 91.25% 91.25% -0.01%
==========================================
Files 461 461
Lines 57490 57519 +29
Branches 5543 5543
==========================================
+ Hits 52465 52491 +26
- Misses 3603 3604 +1
- Partials 1422 1424 +2 ☔ View full report in Codecov by Sentry. |
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.
Looks good, minor nit request 🙃
not (set(op.attributes.keys()) | set(op.properties.keys())) | ||
- self.reserved_attr_names | ||
): | ||
return | ||
if any(name in op.attributes for name in op.properties): | ||
raise ValueError( | ||
"Cannot print attributes and properties with the same name " | ||
"in a signle dictionary" |
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.
Can you fix this typo while you're at it? 🙃
"in a signle dictionary" | |
"in a single dictionary" |
default_names = set( | ||
name | ||
for name, d in op_def.attributes.items() | ||
if d.default_value is not None | ||
and op.attributes.get(name) == d.default_value | ||
) | ||
reserved_or_default = self.reserved_attr_names | default_names | ||
if not set(op.attributes.keys()) - reserved_or_default: |
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.
nit:
default_names = set( | |
name | |
for name, d in op_def.attributes.items() | |
if d.default_value is not None | |
and op.attributes.get(name) == d.default_value | |
) | |
reserved_or_default = self.reserved_attr_names | default_names | |
if not set(op.attributes.keys()) - reserved_or_default: | |
reserved_or_default = self.reserved_attr_names.update( | |
name | |
for name, d in op_def.attributes.items() | |
if d.default_value is not None | |
and op.attributes.get(name) == d.default_value | |
) | |
if not reserved_or_default.is_superset(op.attributes.keys()): |
Two proposals, each of which avoids a set construction, seems a tiny bit cleaner
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.
update is a mutating function right? (I can't mutate self.reserved_attr_names)
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.
My bad, I meant union
Should I still refactor to use |
It's a bit of a nit, and it's unlikely to be a perf bottleneck, but it seems like a good opportunity to do so, sets aren't free :) |
Great, will wait for CI then merge |
The
attr-dict
directive currently prints attributes/properties which are set to the default value, which is not the correct behaviour.