Skip to content

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

This PR is an implementation of new feature request #12760, for setting service_args not only through constructor, but also through setter/getter methods using properties.

Motivation and Context

New feature request 12760

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.

Copy link
Member

@titusfortner titusfortner left a comment

Choose a reason for hiding this comment

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

The move to _service_args looks correct. Otherwise I think there are a few issues that need to be updated. Thanks.

@titusfortner
Copy link
Member

Also, can you rebase with trunk, I think we have conflicts

@sandeepsuryaprasad
Copy link
Contributor Author

I have cleaned it up..

@sandeepsuryaprasad sandeepsuryaprasad changed the title [py] implementation of new feature-12760, setting service_args though getters/setters [py] implementation of new feature-12760, setting service_args through getters/setters Sep 18, 2023
def service_args(self, value):
if not isinstance(value, list):
raise TypeError("service args must be a list")
self._service_args.extend(value)
Copy link

Choose a reason for hiding this comment

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

It might be just me, but the setter seems more like an append rather than replace/set the value.

Is this the intended behaviour? Setters for me usually replace the existing value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

every time when assignment happens to service_args I am not replacing the old args, rather I am updating the existing contents of the list.
e.g.

service = Service(service_args = ["--log", "debug"])
service.service_args = ["--port", 1234]
print(service.service_args)
# prints 
["--log", "debug", "--port", 1234]

@titusfortner , should this be the intended behaviour? or should the old list be replaced with new one every time an assignment happens to service_args?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know the Python convention, but it does feel a little weird to append to something existing with an assignment operator. (They way Ruby does it is so much better 😉). I lean toward replacing instead of adding. @isaulv what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

This should definitely not be a setter as that creates the expectation that it is setting the value that you pass in. It is not intuitive to users that it will extend. We either need a different method name or we should see about closing this PR.

@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2023

Codecov Report

Attention: 63 lines in your changes are missing coverage. Please review.

Comparison is base (741e9f6) 56.53% compared to head (a472b4b) 55.88%.
Report is 67 commits behind head on trunk.

❗ Current head a472b4b differs from pull request most recent head b5d8ba5. Consider uploading reports for the commit b5d8ba5 to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #12767      +/-   ##
==========================================
- Coverage   56.53%   55.88%   -0.66%     
==========================================
  Files          86       86              
  Lines        5253     5316      +63     
  Branches      187      187              
==========================================
+ Hits         2970     2971       +1     
- Misses       2096     2158      +62     
  Partials      187      187              
Files Coverage Δ
py/selenium/__init__.py 100.00% <100.00%> (ø)
py/selenium/webdriver/common/selenium_manager.py 57.89% <100.00%> (-1.57%) ⬇️
py/selenium/webdriver/edge/service.py 68.57% <38.46%> (-19.90%) ⬇️
py/selenium/webdriver/webkitgtk/service.py 62.06% <33.33%> (-22.94%) ⬇️
py/selenium/webdriver/wpewebkit/service.py 62.06% <33.33%> (-22.94%) ⬇️
py/selenium/webdriver/chromium/service.py 62.50% <30.76%> (-24.46%) ⬇️
py/selenium/webdriver/safari/service.py 70.00% <35.71%> (-10.65%) ⬇️
py/selenium/webdriver/ie/service.py 59.37% <37.50%> (-28.13%) ⬇️
py/selenium/webdriver/firefox/service.py 56.25% <31.25%> (-31.25%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@symonk
Copy link
Member

symonk commented Sep 26, 2023

Thanks @sandeepsuryaprasad! These seem to be 'placeholder' getter/setters for things at the moment which python typically doesn't really care about (its not as painful to add them in when required compared to other statically typed languages like java, but I don't really mind if we have them, can help with some validation around setting the service args

)

@property
def service_args(self):
Copy link
Member

Choose a reason for hiding this comment

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

be nice to add typing to things we are adding, feel free to ignore tho as theres plenty of general typing work to do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@symonk thanks for your review comments. I have updated the code.

@titusfortner
Copy link
Member

Sorry this one has languished, can you de-conflict it and I'll review again? Thanks!

@diemol
Copy link
Member

diemol commented Jul 12, 2024

I am closing this because there are several file conflicts, but also, there was no more activity from the OP.

@cgoldberg
Copy link
Member

this was done in #15889

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.

8 participants