-
Notifications
You must be signed in to change notification settings - Fork 78
Add alias support to Property class and related tests #619
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
Add alias support to Property class and related tests #619
Conversation
- Introduced `alias_of` parameter in Property to allow aliasing of API attributes. - Implemented `properties_with_alias` method in Base class to retrieve aliased properties. - Updated BetaProgram to include an aliased property for "class". - Added comprehensive tests for alias functionality in PropertyAliasTest.
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.
Pull request overview
This PR adds support for property aliasing in the Property class, allowing Python-friendly names for API attributes that are reserved words (like "class"). The implementation includes a new alias_of parameter, a properties_with_alias cached property for efficient lookup, and updates to serialization/deserialization logic to handle the mapping between aliased and original attribute names.
Key Changes:
- Added
alias_ofparameter toPropertyclass for mapping Python-safe names to original API attributes - Implemented
properties_with_aliascached property inBaseclass for retrieving aliased properties - Updated
_populateand_serializemethods to correctly handle aliased properties during JSON deserialization and serialization
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| linode_api4/objects/base.py | Added alias support infrastructure including the alias_of parameter, properties_with_alias cached property, and updated serialization/population logic |
| linode_api4/objects/beta.py | Added example usage with beta_class property aliasing the reserved word "class" |
| test/unit/objects/property_alias_test.py | Comprehensive test suite covering alias functionality including population, serialization, multiple aliases, and edge cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ezilber-akamai
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.
Nice work!
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lgarber-akamai
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.
Looks great!
yec-akamai
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.
Nice work!
📝 Description
alias_ofparameter in Property to allow aliasing of API attributes.properties_with_aliasmethod in Base class to retrieve aliased properties.BetaProgramto include an aliased property for "class".PropertyAliasTest.✔️ How to Test