Skip to content

Commit dce00a8

Browse files
navin772harsha509
andauthored
[py] fix mypy errors for input_device.py, ie/options.py and selenium_manager.py (#14377)
Signed-off-by: Navin Chandra <[email protected]> Co-authored-by: Sri Harsha <[email protected]>
1 parent 596070d commit dce00a8

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

py/selenium/webdriver/common/actions/input_device.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# under the License.
1717

1818
import uuid
19+
from typing import Any
20+
from typing import List
1921
from typing import Optional
2022

2123

@@ -24,14 +26,14 @@ class InputDevice:
2426

2527
def __init__(self, name: Optional[str] = None):
2628
self.name = name or uuid.uuid4()
27-
self.actions = []
29+
self.actions: List[Any] = []
2830

29-
def add_action(self, action):
31+
def add_action(self, action: Any) -> None:
3032
""""""
3133
self.actions.append(action)
3234

33-
def clear_actions(self):
35+
def clear_actions(self) -> None:
3436
self.actions = []
3537

36-
def create_pause(self, duration: int = 0):
38+
def create_pause(self, duration: int = 0) -> None:
3739
pass

py/selenium/webdriver/common/selenium_manager.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import sysconfig
2424
from pathlib import Path
2525
from typing import List
26+
from typing import Optional
2627

2728
from selenium.common import WebDriverException
2829

@@ -67,9 +68,11 @@ def _get_binary() -> Path:
6768
if exe is not None:
6869
compiled_path = compiled_path.with_suffix(exe)
6970

70-
if (path := os.getenv("SE_MANAGER_PATH")) is not None:
71-
logger.debug("Selenium Manager set by env SE_MANAGER_PATH to: %s", path)
72-
path = Path(path)
71+
path: Optional[Path] = None
72+
73+
if (env_path := os.getenv("SE_MANAGER_PATH")) is not None:
74+
logger.debug("Selenium Manager set by env SE_MANAGER_PATH to: %s", env_path)
75+
path = Path(env_path)
7376
elif compiled_path.exists():
7477
path = compiled_path
7578
else:
@@ -92,7 +95,7 @@ def _get_binary() -> Path:
9295

9396
path = Path(__file__).parent.joinpath(location)
9497

95-
if not path.is_file():
98+
if path is None or not path.is_file():
9699
raise WebDriverException(f"Unable to obtain working Selenium Manager binary; {path}")
97100

98101
logger.debug("Selenium Manager binary found at: %s", path)

py/selenium/webdriver/ie/options.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
from enum import Enum
18+
from typing import Any
19+
from typing import Dict
1820

1921
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
2022
from selenium.webdriver.common.options import ArgOptions
@@ -362,8 +364,8 @@ class Options(ArgOptions):
362364

363365
def __init__(self) -> None:
364366
super().__init__()
365-
self._options = {}
366-
self._additional = {}
367+
self._options: Dict[str, Any] = {}
368+
self._additional: Dict[str, Any] = {}
367369

368370
@property
369371
def options(self) -> dict:
@@ -375,7 +377,7 @@ def additional_options(self) -> dict:
375377
""":Returns: The additional options."""
376378
return self._additional
377379

378-
def add_additional_option(self, name: str, value):
380+
def add_additional_option(self, name: str, value) -> None:
379381
"""Adds an additional option not yet added as a safe option for IE.
380382
381383
:Args:

0 commit comments

Comments
 (0)