Skip to content

[py] PEP484 hints for webdriver.common.actions.action_builder#10108

Merged
titusfortner merged 8 commits intoSeleniumHQ:trunkfrom
iampopovich:PEP-484/webdriver_common_action_builder
Dec 24, 2021
Merged

[py] PEP484 hints for webdriver.common.actions.action_builder#10108
titusfortner merged 8 commits intoSeleniumHQ:trunkfrom
iampopovich:PEP-484/webdriver_common_action_builder

Conversation

@iampopovich
Copy link
Copy Markdown
Contributor

@iampopovich iampopovich commented Dec 1, 2021

Description

This PR adds type hints to selenium.webdriver.common.actions.action_builder

also method get_device_with was edited much more laconic
old:

    def get_device_with(self, name):
        try:
            idx = self.devices.index(name)
            return self.devices[idx]
        except Exception:
            pass

new:

    def get_device_with(self, name) -> Union["WheelInput","PointerInput","KeyInput"]:
        return next(filter(lambda x: x == name, self.devices), None)
  • new variant has the same execution time as old get_device_with
  • method returns None (as old try/except) if no device was filtered
  • try/except block is unnecessary anymore

Motivation and Context

This is a follow-up of #9482 to address #9480.
@AutomatedTester pls review

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.

…builder

also method get_device_with was edited much more laconic
new variant has the same execution time as old get_device_with
method returns None (as old try/except) if no device was filtered
try/except block is unnecessary anymore
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 1, 2021

Codecov Report

Merging #10108 (03b326e) into trunk (932ac99) will increase coverage by 0.17%.
The diff coverage is 53.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##            trunk   #10108      +/-   ##
==========================================
+ Coverage   44.90%   45.08%   +0.17%     
==========================================
  Files          86       86              
  Lines        5663     5661       -2     
  Branches      265      266       +1     
==========================================
+ Hits         2543     2552       +9     
+ Misses       2855     2843      -12     
- Partials      265      266       +1     
Impacted Files Coverage Δ
...elenium/webdriver/common/actions/action_builder.py 39.65% <53.33%> (+12.98%) ⬆️
py/selenium/webdriver/common/action_chains.py 24.03% <0.00%> (+1.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 932ac99...03b326e. Read the comment docs.

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@titusfortner titusfortner merged commit 34a3aa2 into SeleniumHQ:trunk Dec 24, 2021
@iampopovich iampopovich deleted the PEP-484/webdriver_common_action_builder branch December 25, 2021 00:17
elgatov pushed a commit to elgatov/selenium that referenced this pull request Jun 27, 2022
…builder (SeleniumHQ#10108)

also method get_device_with was edited much more laconic
new variant has the same execution time as old get_device_with
method returns None (as old try/except) if no device was filtered
try/except block is unnecessary anymore
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