Skip to content

Commit

Permalink
[py] fix type hints for selenium.webdriver.remote.file_detector (Sele…
Browse files Browse the repository at this point in the history
…niumHQ#9647)

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
  • Loading branch information
hoefling committed Jul 13, 2021
1 parent 6b2edbc commit 77788e0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
23 changes: 23 additions & 0 deletions py/selenium/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

"""Selenium type definitions."""

from typing import Union


AnyKey = Union[str, int, float]
2 changes: 1 addition & 1 deletion py/selenium/webdriver/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
from typing import Iterable, List, Optional, Union

import socket
from selenium.types import AnyKey
from selenium.webdriver.common.keys import Keys

AnyKey = Union[str, int, float]

_is_connectable_exceptions = (socket.error, ConnectionResetError)

Expand Down
8 changes: 4 additions & 4 deletions py/selenium/webdriver/remote/file_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from abc import ABCMeta, abstractmethod
import os
from typing import Optional
from selenium.types import AnyKey
from selenium.webdriver.common.utils import keys_to_typing
# from selenium.types import AnyKey


class FileDetector(metaclass=ABCMeta):
Expand All @@ -29,7 +29,7 @@ class FileDetector(metaclass=ABCMeta):
"""

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


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

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


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

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

if not file_path:
Expand Down

0 comments on commit 77788e0

Please sign in to comment.