Skip to content

Commit e096077

Browse files
committed
addressing mypy errors
1 parent 12757f0 commit e096077

File tree

7 files changed

+27
-18
lines changed

7 files changed

+27
-18
lines changed

py/selenium/webdriver/chrome/service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ class Service(service.ChromiumService):
3333
:param log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
3434
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
3535
"""
36-
36+
_service_args: list[str]
3737
def __init__(
3838
self,
3939
executable_path: Optional[str] = None,
4040
port: int = 0,
41-
service_args: Optional[Sequence[str]] = None,
41+
service_args: Optional[list[str]] = None,
4242
log_output: Optional[SubprocessStdAlias] = None,
4343
env: Optional[Mapping[str, str]] = None,
4444
**kwargs,
@@ -55,11 +55,11 @@ def __init__(
5555
)
5656

5757
@property
58-
def service_args(self) -> Sequence[str]:
58+
def service_args(self) -> list[str]:
5959
return self._service_args
6060

6161
@service_args.setter
62-
def service_args(self, value: Sequence[str]):
62+
def service_args(self, value: list[str]):
6363
if isinstance(value, str) or not isinstance(value, Sequence):
6464
raise TypeError("service_args must be a sequence")
6565
self._service_args = list(value)

py/selenium/webdriver/chrome/webdriver.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
class WebDriver(ChromiumDriver):
2828
"""Controls the ChromeDriver and allows you to drive the browser."""
2929

30+
options: Options
31+
service: Service
32+
3033
def __init__(
3134
self,
3235
options: Optional[Options] = None,

py/selenium/webdriver/chromium/service.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from collections.abc import Mapping, Sequence
1919
from io import IOBase
20-
from typing import Optional
20+
from typing import Optional, Union
2121

2222
from selenium.types import SubprocessStdAlias
2323
from selenium.webdriver.common import service
@@ -34,12 +34,14 @@ class ChromiumService(service.Service):
3434
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
3535
:param driver_path_env_key: (Optional) Environment variable to use to get the path to the driver executable.
3636
"""
37+
_service_args: list[str]
38+
log_output: Union[Optional[IOBase], Optional[Union[int, IOBase]], Optional[SubprocessStdAlias]]
3739

3840
def __init__(
3941
self,
4042
executable_path: Optional[str] = None,
4143
port: int = 0,
42-
service_args: Optional[Sequence[str]] = None,
44+
service_args: Optional[list[str]] = None,
4345
log_output: Optional[SubprocessStdAlias] = None,
4446
env: Optional[Mapping[str, str]] = None,
4547
driver_path_env_key: Optional[str] = None,
@@ -69,11 +71,11 @@ def command_line_args(self) -> list[str]:
6971
return [f"--port={self.port}"] + self._service_args
7072

7173
@property
72-
def service_args(self) -> Sequence[str]:
74+
def service_args(self) -> list[str]:
7375
return self._service_args
7476

7577
@service_args.setter
76-
def service_args(self, value: Sequence[str]):
78+
def service_args(self, value: list[str]):
7779
if isinstance(value, str) or not isinstance(value, Sequence):
7880
raise TypeError("service_args must be a sequence")
7981
self._service_args = list(value)

py/selenium/webdriver/chromium/webdriver.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from typing import Optional
1918

19+
from selenium.webdriver.chromium.options import ChromiumOptions
2020
from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection
21+
from selenium.webdriver.chromium.service import ChromiumService
2122
from selenium.webdriver.common.driver_finder import DriverFinder
22-
from selenium.webdriver.common.options import ArgOptions
23-
from selenium.webdriver.common.service import Service
2423
from selenium.webdriver.remote.command import Command
2524
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
2625

@@ -31,10 +30,10 @@ class ChromiumDriver(RemoteWebDriver):
3130

3231
def __init__(
3332
self,
34-
browser_name: Optional[str] = None,
35-
vendor_prefix: Optional[str] = None,
36-
options: ArgOptions = ArgOptions(),
37-
service: Optional[Service] = None,
33+
browser_name: str,
34+
vendor_prefix: str,
35+
options: ChromiumOptions = ChromiumOptions(),
36+
service: ChromiumService = ChromiumService(),
3837
keep_alive: bool = True,
3938
) -> None:
4039
"""Creates a new WebDriver instance of the ChromiumDriver. Starts the

py/selenium/webdriver/common/service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class Service(ABC):
4848
:param driver_path_env_key: (Optional) Environment variable to use to get the path to the driver executable.
4949
"""
5050

51+
log_output: Union[Optional[IOBase], Optional[Union[int, IOBase]], Optional[SubprocessStdAlias]]
52+
5153
def __init__(
5254
self,
5355
executable_path: Optional[str] = None,

py/selenium/webdriver/edge/service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(
3939
executable_path: Optional[str] = None,
4040
port: int = 0,
4141
log_output: Optional[SubprocessStdAlias] = None,
42-
service_args: Optional[Sequence[str]] = None,
42+
service_args: Optional[list[str]] = None,
4343
env: Optional[Mapping[str, str]] = None,
4444
driver_path_env_key: Optional[str] = None,
4545
**kwargs,
@@ -58,11 +58,11 @@ def __init__(
5858
)
5959

6060
@property
61-
def service_args(self) -> Sequence[str]:
61+
def service_args(self) -> list[str]:
6262
return self._service_args
6363

6464
@service_args.setter
65-
def service_args(self, value: Sequence[str]):
65+
def service_args(self, value: list[str]):
6666
if isinstance(value, str) or not isinstance(value, Sequence):
6767
raise TypeError("service_args must be a sequence")
6868
self._service_args = list(value)

py/selenium/webdriver/edge/webdriver.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
class WebDriver(ChromiumDriver):
2828
"""Controls the MSEdgeDriver and allows you to drive the browser."""
2929

30+
options: Options
31+
service: Service
32+
3033
def __init__(
3134
self,
3235
options: Optional[Options] = None,

0 commit comments

Comments
 (0)