Skip to content

Commit 16c3e24

Browse files
committed
[py]:Fix mypy type errors in webdriver
1 parent e943cc1 commit 16c3e24

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

py/selenium/webdriver/common/virtual_authenticator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(
8080
self,
8181
credential_id: bytes,
8282
is_resident_credential: bool,
83-
rp_id: str,
83+
rp_id: Optional[str],
8484
user_handle: Optional[bytes],
8585
private_key: bytes,
8686
sign_count: int,
@@ -112,7 +112,7 @@ def is_resident_credential(self) -> bool:
112112
return self._is_resident_credential
113113

114114
@property
115-
def rp_id(self) -> str:
115+
def rp_id(self) -> Optional[str]:
116116
return self._rp_id
117117

118118
@property

py/selenium/webdriver/remote/errorhandler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ def check_response(self, response: dict[str, Any]) -> None:
173173
message = value.get("value") or value.get("message")
174174
if not isinstance(message, str):
175175
value = message
176-
message = message.get("message")
176+
if isinstance(message, dict):
177+
message = message.get("message")
177178
else:
178179
message = value.get("message", None)
179180
except ValueError:

py/selenium/webdriver/webkitgtk/service.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
import shutil
1919
import warnings
2020
from collections.abc import Mapping
21-
from typing import Optional, Sequence
21+
from typing import IO, Optional, Sequence
2222

2323
from selenium.webdriver.common import service
2424

25-
DEFAULT_EXECUTABLE_PATH: str = shutil.which("WebKitWebDriver")
25+
DEFAULT_EXECUTABLE_PATH: Optional[str] = shutil.which("WebKitWebDriver")
2626

2727

2828
class Service(service.Service):
@@ -40,7 +40,7 @@ class Service(service.Service):
4040

4141
def __init__(
4242
self,
43-
executable_path: str = DEFAULT_EXECUTABLE_PATH,
43+
executable_path: Optional[str] = DEFAULT_EXECUTABLE_PATH,
4444
port: int = 0,
4545
log_path: Optional[str] = None,
4646
log_output: Optional[str] = None,
@@ -49,15 +49,19 @@ def __init__(
4949
**kwargs,
5050
) -> None:
5151
self._service_args = list(service_args or [])
52+
53+
log_file: Optional[IO[bytes]] = None
54+
5255
if log_path is not None:
5356
warnings.warn("log_path is deprecated, use log_output instead", DeprecationWarning, stacklevel=2)
54-
log_path = open(log_path, "wb")
55-
log_output = open(log_output, "wb") if log_output else None
57+
log_file = open(log_path, "wb")
58+
elif log_output is not None:
59+
log_file = open(log_output, "wb")
5660

5761
super().__init__(
5862
executable_path=executable_path,
5963
port=port,
60-
log_output=log_path or log_output,
64+
log_output=log_file,
6165
env=env,
6266
**kwargs,
6367
)

py/selenium/webdriver/wpewebkit/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Service(service.Service):
3939

4040
def __init__(
4141
self,
42-
executable_path: str = DEFAULT_EXECUTABLE_PATH,
42+
executable_path: Optional[str] = DEFAULT_EXECUTABLE_PATH,
4343
port: int = 0,
4444
log_output: Optional[str] = None,
4545
service_args: Optional[Sequence[str]] = None,

0 commit comments

Comments
 (0)