Skip to content

Commit 77788e0

Browse files
authored
[py] fix type hints for selenium.webdriver.remote.file_detector (#9647)
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
1 parent 6b2edbc commit 77788e0

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

py/selenium/types.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
"""Selenium type definitions."""
19+
20+
from typing import Union
21+
22+
23+
AnyKey = Union[str, int, float]

py/selenium/webdriver/common/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
from typing import Iterable, List, Optional, Union
2323

2424
import socket
25+
from selenium.types import AnyKey
2526
from selenium.webdriver.common.keys import Keys
2627

27-
AnyKey = Union[str, int, float]
2828

2929
_is_connectable_exceptions = (socket.error, ConnectionResetError)
3030

py/selenium/webdriver/remote/file_detector.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
from abc import ABCMeta, abstractmethod
1919
import os
2020
from typing import Optional
21+
from selenium.types import AnyKey
2122
from selenium.webdriver.common.utils import keys_to_typing
22-
# from selenium.types import AnyKey
2323

2424

2525
class FileDetector(metaclass=ABCMeta):
@@ -29,7 +29,7 @@ class FileDetector(metaclass=ABCMeta):
2929
"""
3030

3131
@abstractmethod
32-
def is_local_file(self, *keys) -> Optional[str]:
32+
def is_local_file(self, *keys: AnyKey) -> Optional[str]:
3333
return None
3434

3535

@@ -38,7 +38,7 @@ class UselessFileDetector(FileDetector):
3838
A file detector that never finds anything.
3939
"""
4040

41-
def is_local_file(self, *keys) -> Optional[str]:
41+
def is_local_file(self, *keys: AnyKey) -> Optional[str]:
4242
return None
4343

4444

@@ -47,7 +47,7 @@ class LocalFileDetector(FileDetector):
4747
Detects files on the local disk.
4848
"""
4949

50-
def is_local_file(self, *keys) -> Optional[str]:
50+
def is_local_file(self, *keys: AnyKey) -> Optional[str]:
5151
file_path = ''.join(keys_to_typing(keys))
5252

5353
if not file_path:

0 commit comments

Comments
 (0)