-
Notifications
You must be signed in to change notification settings - Fork 6
Add access_mode property to Attribute classes (#260) #307
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
base: main
Are you sure you want to change the base?
Conversation
Resolves #260 by adding an access_mode property to Attribute and its subclasses, replacing the need for the _attribute_to_access() free function. The property returns "r" for AttrR, "w" for AttrW, and "rw" for AttrRW, providing a cleaner API for determining attribute access modes. - Add AttributeAccessMode type definition to attribute.py - Make Attribute class abstract with abstract access_mode property - Implement access_mode property in AttrR, AttrW, and AttrRW - Export AttributeAccessMode from attributes module - Replace _attribute_to_access() function usage in PVA PVI code - Remove _attribute_to_access() function and TODO comment - Add unit test for the new access_mode property All tests and type checking pass. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #307 +/- ##
==========================================
+ Coverage 90.69% 90.78% +0.09%
==========================================
Files 70 70
Lines 2535 2540 +5
==========================================
+ Hits 2299 2306 +7
+ Misses 236 234 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
shihab-dls
left a comment
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.
Wow, simple issue, but I'm getting red-pilled by Claude. Looks good, approving.
| # Verify type compatibility | ||
| mode_r: AttributeAccessMode = attr_r.access_mode | ||
| mode_w: AttributeAccessMode = attr_w.access_mode | ||
| mode_rw: AttributeAccessMode = attr_rw.access_mode | ||
|
|
||
| assert isinstance(mode_r, str) | ||
| assert isinstance(mode_w, str) | ||
| assert isinstance(mode_rw, str) |
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.
I think I'll remove this, it seems excessive
Summary
Resolves #260 by adding an
access_modeproperty to the Attribute class hierarchy, replacing the_attribute_to_access()free function.Changes
AttributeAccessModetype definition (Literal["r", "w", "rw"]) to the attributes moduleAttributeclass abstract with an abstractaccess_modepropertyaccess_modein all attribute subclasses:AttrR: returns"r"AttrW: returns"w"AttrRW: returns"rw"AttributeAccessModefrom the attributes module_attribute_to_access()function usage in PVA PVI code with the new property_attribute_to_access()function and its TODO commentTest plan
tox -e tests)tox -e type-checking)test_attribute_access_mode()verifies the property returns correct valuesBackward Compatibility
This change is fully backward compatible:
_attribute_to_access()function was internal only, never part of public API🤖 Generated with Claude Code