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] Refactored Proxy object in common/proxy.py using custom descriptor. #12286

Merged
merged 3 commits into from
Jul 5, 2023

Conversation

sandeepsuryaprasad
Copy link
Contributor

@sandeepsuryaprasad sandeepsuryaprasad commented Jun 29, 2023

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

Moved all below ProxyTypes which has common operations in getter and setter methods to one single descriptor class. Also, I have re-factored to_capabilities method by eliminating multiple conditionals.

autodetect 
ftpProxy
httpProxy
noProxy
proxyAutoconfigUrl
sslProxy
socksProxy
socksUsername
socksPassword
socksVersion

This is the same PR (12280) that I closed as I had some issues with the branch that I was working with.
In this PR, I have incorporated the change that @AutomatedTester had asked. (giving blank lines between docstring and descriptor object)

Motivation and Context

  • By Moving all ProxyType getters and setters to custom descriptors, multiple properties are being eliminated.
  • Currently there are 10 pairs of property with 20 methods. All doing similar job of validating the proxy type and assigning a class attribute with some proxy, there is lot of code repetition.
  • This is now completely optimised by moving all properties to descriptor class.
  • This reduces maintenance effort since the entire logic of attribute assignment lies in __set__ method of descriptor.
  • Also, refactored to_capabilites method in Proxy class by eliminating multiple conditional statements.

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: 2.70% and project coverage change: +0.37 🎉

Comparison is base (50f9252) 56.92% compared to head (b543937) 57.29%.

❗ Current head b543937 differs from pull request most recent head eff7ec3. Consider uploading reports for the commit eff7ec3 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   #12286      +/-   ##
==========================================
+ Coverage   56.92%   57.29%   +0.37%     
==========================================
  Files          86       86              
  Lines        5423     5367      -56     
  Branches      193      193              
==========================================
- Hits         3087     3075      -12     
+ Misses       2143     2099      -44     
  Partials      193      193              
Impacted Files Coverage Δ
py/selenium/webdriver/common/proxy.py 15.09% <2.70%> (-2.19%) ⬇️

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

@diemol diemol merged commit 669fbb3 into SeleniumHQ:trunk Jul 5, 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.

4 participants