Skip to content
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

[py] instance attributes in Timeout class are now being set through setter… #12186

Merged
merged 1 commit into from
Jun 9, 2023

Conversation

sandeepsuryaprasad
Copy link
Contributor

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

[py] all assignments to instance attributes in Timeouts class are now being set through setter method.

Motivation and Context

  1. In class Timeouts under common/timeouts.py, three instance attributes are being set in the __init__ method.
    self._implicit_wait, self._page_load and self._script.

  2. The problem with this approach is that we are directly assigning converted values from self._convert method to internal variables self._implicit_wait, self._page_load and self._script by by-passing setter methods ( @implicit_wait.setter, @page_load.setter, @script.setter) while creating of the object.

  3. The setter methods comes into play only when we are directly assigning values to instance attributes, e.g. self.implicit_wait = 10 or self.page_load = 30. Now this assignment goes through setter methods.

  4. Ultimately the setter methods are setting values to internal variables _implicit_wait, _page_load and _script.

  5. So the change that I am suggesting is that, instead of directly assigning internal attributes in __init__ method, let the assignment go through setter method.

self.implicit_wait = implicit_wait
self.page_load = page_load
self.script = script

the above statements would call corresponding setter methods, which in-turn sets internal attributes _implicit_wait, _page_load and _script. In this case we are doing an assignment to a property descriptor (data descriptor) which goes through @implicit_wait.setter, @page_load.setter, @script.setter methods.

  1. I believe this change will not break any of the existing code base, since we are not renaming any attributes.

Types of changes

  • [] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • [] My change requires a change to the documentation.
  • [] I have updated the documentation accordingly.
  • [] I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (a50bfe2) 56.56% compared to head (93ec62a) 56.56%.

❗ Current head 93ec62a differs from pull request most recent head 16858cc. Consider uploading reports for the commit 16858cc to get more accurate results

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #12186   +/-   ##
=======================================
  Coverage   56.56%   56.56%           
=======================================
  Files          86       86           
  Lines        5450     5450           
  Branches      223      223           
=======================================
  Hits         3083     3083           
  Misses       2144     2144           
  Partials      223      223           
Impacted Files Coverage Δ
py/selenium/webdriver/common/timeouts.py 93.33% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @sandeepsuryaprasad!

@diemol diemol merged commit 3dc8903 into SeleniumHQ:trunk Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants