Skip to content

Commit 3a788a3

Browse files
committed
[py]: docs and type hints for chrome.service
1 parent 1fa4ca6 commit 3a788a3

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

py/selenium/types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121

2222
AnyKey = typing.Union[str, int, float]
2323
WaitExcTypes = typing.Iterable[typing.Type[Exception]]
24+
25+
# Service Types
26+
SubprocessStdAlias = typing.Union[int, typing.IO[typing.Any]]

py/selenium/webdriver/chrome/service.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,37 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
18-
from typing import List
17+
import typing
1918

2019
from selenium.webdriver.chromium import service
2120

2221
DEFAULT_EXECUTABLE_PATH = "chromedriver"
2322

2423

2524
class Service(service.ChromiumService):
26-
"""
27-
Object that manages the starting and stopping of the ChromeDriver
25+
"""A Service class that is responsible for the starting and stopping
26+
of `chromedriver`.
27+
28+
:param executable_path: install path of the chromedriver executable, defaults to `chromedriver`.
29+
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
30+
:param service_args: (Optional) Sequence of args/flags to be passed to the `chromedriver` subprocess.
31+
:param log_path: (Optional) String to be passed to the executable as `--log-path`
32+
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
2833
"""
2934

3035
def __init__(
3136
self,
3237
executable_path: str = DEFAULT_EXECUTABLE_PATH,
3338
port: int = 0,
34-
service_args: List[str] = None,
35-
log_path: str = None,
36-
env: dict = None,
37-
):
38-
"""
39-
Creates a new instance of the Service
40-
41-
:Args:
42-
- executable_path : Path to the ChromeDriver
43-
- port : Port the service is running on
44-
- service_args : List of args to pass to the chromedriver service
45-
- log_path : Path for the chromedriver service to log to"""
46-
39+
service_args: typing.Optional[typing.Sequence[str]] = None,
40+
log_path: typing.Optional[str] = None,
41+
env: typing.Optional[typing.Mapping[str, str]] = None,
42+
) -> None:
4743
super().__init__(
48-
executable_path, port, service_args, log_path, env, "Please see https://chromedriver.chromium.org/home"
44+
executable_path=executable_path,
45+
port=port,
46+
service_args=service_args,
47+
log_path=log_path,
48+
env=env,
49+
start_error_message="Please see https://chromedriver.chromium.org/home",
4950
)

py/selenium/webdriver/chromium/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(
3030
executable_path: str,
3131
port: int = 0,
3232
service_args: typing.Optional[List[str]] = None,
33-
log_path: typing.Optional[typing.Union[str, int]] = None,
33+
log_path: typing.Optional[str] = None,
3434
env: typing.Optional[typing.Dict[typing.Any, typing.Any]] = None,
3535
start_error_message: str = "",
3636
):

0 commit comments

Comments
 (0)