-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[py] Now the ClientWindowInfo
object's attributes are validated through getters/setters
#16093
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: trunk
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
@navin772 can you please re-trigger the CI. I have fixed the formatting issue that i missed.. Thanks! |
@cgoldberg can we have this one merged.. |
User description
🔗 Related Issues
💥 What does this PR do?
In this PR, I have encapsulated all instance attributes of
ClientWindowInfo
class ingetters/setters
and now the attributes are being validated throughsetters
🔧 Implementation Notes
It is not a standard practice to validate instance attributes inside a class method. More Pythonic approach is to have separate
getters/setters
to do the validations. The class methodfrom_dict
is cluttered with validations of different instance attributes before the class is getting instantiated. The more standard and structured approach for this is to validate throughsetters
. After the changes made in this PR, the class method looks clean and readable.In the current implementation although there are few getter methods like,
get_state
,get_client_window
,get_width
,get_height
,get_x
,get_y
, which returns the value of corresponding attributes, the setting of these attributes are done in constructor, but the validations before they are being set is done in class methodfrom_dict
which I felt is bit strange.The getters in the current code is not in pythonic style and it is Java way of doing things. The more pythonic approach is to have
property
descriptors, which I have implemented in this PR.💡 Additional Considerations
🔄 Types of changes
PR Type
Enhancement
Description
Refactored
ClientWindowInfo
class to use Python properties instead of getter methodsAdded validation in property setters for all attributes
Simplified
from_dict
class method by removing inline validationsUpdated tests to use property access instead of getter methods
Diagram Walkthrough
File Walkthrough
browser.py
Convert getters to properties with validation
py/selenium/webdriver/common/bidi/browser.py
@property
decoratorsfrom_dict
method by removing validation codebidi_browser_tests.py
Update tests for property access
py/test/selenium/webdriver/common/bidi_browser_tests.py
methods
get_client_window()
toclient_window
property accessget_state()
,get_width()
,get_height()
,get_x()
,get_y()
todirect property access