Skip to content

Conversation

@thecr8tr
Copy link
Contributor

@thecr8tr thecr8tr commented Jan 1, 2022

Description

This PR adds type hints to selenium.webdriver.chrome.options

Motivation and Context

This is an action towards #9480.

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.

@CLAassistant
Copy link

CLAassistant commented Jan 1, 2022

CLA assistant check
All committers have signed the CLA.

@titusfortner
Copy link
Member

Should this be None instead of NoReturn?

@titusfortner
Copy link
Member

@colons you have a very different implementation for enable_mobile for Firefox. (I'm assuming Chrome vs Firefox shouldn't be different)...

self, android_package: Optional[str] = "org.mozilla.firefox", android_activity: str = None, device_serial: str = None

@colons
Copy link
Contributor

colons commented Jan 4, 2022

@titusfortner im not sure what difference exactly you're worried about here; the wrapping of optional kwargs with Optional is a matter of preference, for instance. annotating BaseOptions.enable_mobile() would be a good idea if you want mypy to complain at you if your subclasses are doing incompatible things

certainly, though, NoReturn is incorrect here, and i hope #10202 will make it easier to notice when new annotations are wrong

@titusfortner
Copy link
Member

@colons — I thought everything in Python had a one true way for things. :)
Thanks for clarifying and providing the link.

android_package: str = "com.android.chrome",
android_activity: Optional[str] = None,
device_serial: Optional[str] = None
) -> NoReturn:
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be None not NoReturn

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I corrected that and pushed it. Should we be revisiting NoReturn usage in other places such as https://github.com/SeleniumHQ/selenium/blob/trunk/py/selenium/webdriver/firefox/webdriver.py#L186 ?

Copy link
Member

@titusfortner titusfortner Jan 4, 2022

Choose a reason for hiding this comment

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

Yes! @colons already did that here — #10202
I was trying to figure out why the bazel build //py:test-remote is failing before merging that one, but as discussed on Slack, I can't seem to get it to run on my machine at all.

@titusfortner titusfortner merged commit 0f0ffa0 into SeleniumHQ:trunk Jan 4, 2022
elgatov pushed a commit to elgatov/selenium that referenced this pull request Jun 27, 2022
* PEP484 hints for py/selenium/webdriver/chrome/options.py (SeleniumHQ#10212)
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