Skip to content

Commit

Permalink
[py]: new tox recipe for isort in non diff only mode (#11005)
Browse files Browse the repository at this point in the history
* [py]: Automatically format `test/` with new `isort` recipe

* [py]: use single line imports with isort

* [py]: apply `isort` to all python files in `selenium/` & `test/`
  • Loading branch information
symonk authored Sep 30, 2022
1 parent 316f973 commit 3167e93
Show file tree
Hide file tree
Showing 99 changed files with 308 additions and 253 deletions.
1 change: 0 additions & 1 deletion py/selenium/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
from .exceptions import UnknownMethodException
from .exceptions import WebDriverException


__all__ = ["WebDriverException",
"InvalidSwitchToTargetException",
"NoSuchFrameException",
Expand Down
3 changes: 2 additions & 1 deletion py/selenium/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
Exceptions that may happen in all the webdriver code.
"""

from typing import Optional, Sequence
from typing import Optional
from typing import Sequence


class WebDriverException(Exception):
Expand Down
1 change: 0 additions & 1 deletion py/selenium/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@

import typing


AnyKey = typing.Union[str, int, float]
WaitExcTypes = typing.Iterable[typing.Type[Exception]]
28 changes: 14 additions & 14 deletions py/selenium/webdriver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
# specific language governing permissions and limitations
# under the License.

from .firefox.webdriver import WebDriver as Firefox # noqa
from .chrome.options import Options as ChromeOptions # noqa
from .chrome.webdriver import WebDriver as Chrome # noqa
from .common.action_chains import ActionChains # noqa
from .common.desired_capabilities import DesiredCapabilities # noqa
from .common.keys import Keys # noqa
from .common.proxy import Proxy # noqa
from .edge.options import Options as EdgeOptions # noqa
from .edge.webdriver import WebDriver as ChromiumEdge # noqa
from .edge.webdriver import WebDriver as Edge # noqa
from .firefox.firefox_profile import FirefoxProfile # noqa
from .firefox.options import Options as FirefoxOptions # noqa
from .chrome.webdriver import WebDriver as Chrome # noqa
from .chrome.options import Options as ChromeOptions # noqa
from .ie.webdriver import WebDriver as Ie # noqa
from .firefox.webdriver import WebDriver as Firefox # noqa
from .ie.options import Options as IeOptions # noqa
from .edge.webdriver import WebDriver as Edge # noqa
from .edge.webdriver import WebDriver as ChromiumEdge # noqa
from .edge.options import Options as EdgeOptions # noqa
from .ie.webdriver import WebDriver as Ie # noqa
from .remote.webdriver import WebDriver as Remote # noqa
from .safari.webdriver import WebDriver as Safari # noqa
from .webkitgtk.webdriver import WebDriver as WebKitGTK # noqa
from .webkitgtk.options import Options as WebKitGTKOptions # noqa
from .wpewebkit.webdriver import WebDriver as WPEWebKit # noqa
from .webkitgtk.webdriver import WebDriver as WebKitGTK # noqa
from .wpewebkit.options import Options as WPEWebKitOptions # noqa
from .remote.webdriver import WebDriver as Remote # noqa
from .common.desired_capabilities import DesiredCapabilities # noqa
from .common.action_chains import ActionChains # noqa
from .common.proxy import Proxy # noqa
from .common.keys import Keys # noqa
from .wpewebkit.webdriver import WebDriver as WPEWebKit # noqa

__version__ = '4.5.0'

Expand Down
3 changes: 2 additions & 1 deletion py/selenium/webdriver/chrome/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
# specific language governing permissions and limitations
# under the License.

from typing import Optional

from selenium.webdriver.chromium.options import ChromiumOptions
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from typing import Optional


class Options(ChromiumOptions):
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/chrome/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# under the License.

from typing import List
from selenium.webdriver.chromium import service

from selenium.webdriver.chromium import service

DEFAULT_EXECUTABLE_PATH = "chromedriver"

Expand Down
7 changes: 5 additions & 2 deletions py/selenium/webdriver/chrome/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
# specific language governing permissions and limitations
# under the License.
import warnings

from selenium.webdriver.chromium.webdriver import ChromiumDriver
from .options import Options
from .service import DEFAULT_EXECUTABLE_PATH, Service
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

from .options import Options
from .service import DEFAULT_EXECUTABLE_PATH
from .service import Service

DEFAULT_PORT = 0
DEFAULT_SERVICE_LOG_PATH = None
DEFAULT_KEEP_ALIVE = None
Expand Down
4 changes: 3 additions & 1 deletion py/selenium/webdriver/chromium/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import base64
import os
import warnings
from typing import List, Union, BinaryIO
from typing import BinaryIO
from typing import List
from typing import Union

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.options import ArgOptions
Expand Down
1 change: 1 addition & 0 deletions py/selenium/webdriver/chromium/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

from typing import List

from selenium.webdriver.common import service


Expand Down
8 changes: 4 additions & 4 deletions py/selenium/webdriver/chromium/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
# specific language governing permissions and limitations
# under the License.

from selenium.webdriver.common.options import BaseOptions
from selenium.webdriver.common.service import Service
from selenium.webdriver.edge.options import Options as EdgeOptions
from selenium.webdriver.chrome.options import Options as ChromeOptions
import warnings

from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection
from selenium.webdriver.common.options import BaseOptions
from selenium.webdriver.common.service import Service
from selenium.webdriver.edge.options import Options as EdgeOptions
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver

DEFAULT_PORT = 0
Expand Down
6 changes: 3 additions & 3 deletions py/selenium/webdriver/common/action_chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"""
import warnings

from .actions.wheel_input import ScrollOrigin
from selenium.webdriver.remote.webelement import WebElement

from .utils import keys_to_typing
from .actions.action_builder import ActionBuilder
from selenium.webdriver.remote.webelement import WebElement
from .actions.wheel_input import ScrollOrigin
from .utils import keys_to_typing


class ActionChains:
Expand Down
7 changes: 5 additions & 2 deletions py/selenium/webdriver/common/actions/action_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
# specific language governing permissions and limitations
# under the License.

from typing import Union, List
from typing import List
from typing import Union

from selenium.webdriver.remote.command import Command

from . import interaction
from .key_actions import KeyActions
from .key_input import KeyInput
from .pointer_actions import PointerActions
from .pointer_input import PointerInput
from .wheel_input import WheelInput
from .wheel_actions import WheelActions
from .wheel_input import WheelInput


class ActionBuilder:
Expand Down
5 changes: 3 additions & 2 deletions py/selenium/webdriver/common/actions/key_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from .interaction import Interaction, KEY
from .key_input import KeyInput
from ..utils import keys_to_typing
from .interaction import KEY
from .interaction import Interaction
from .key_input import KeyInput


class KeyActions(Interaction):
Expand Down
5 changes: 2 additions & 3 deletions py/selenium/webdriver/common/actions/key_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
# specific language governing permissions and limitations
# under the License.
from . import interaction

from .input_device import InputDevice
from .interaction import (Interaction,
Pause)
from .interaction import Interaction
from .interaction import Pause


class KeyInput(InputDevice):
Expand Down
1 change: 1 addition & 0 deletions py/selenium/webdriver/common/actions/pointer_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

from selenium.webdriver.remote.webelement import WebElement

from . import interaction
from .interaction import Interaction
from .mouse_button import MouseButton
Expand Down
4 changes: 3 additions & 1 deletion py/selenium/webdriver/common/actions/pointer_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

from selenium.common.exceptions import InvalidArgumentException
from selenium.webdriver.remote.webelement import WebElement

from .input_device import InputDevice
from .interaction import POINTER, POINTER_KINDS
from .interaction import POINTER
from .interaction import POINTER_KINDS


class PointerInput(InputDevice):
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/common/actions/wheel_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from .wheel_input import WheelInput
from .interaction import Interaction
from .wheel_input import WheelInput


class WheelActions(Interaction):
Expand Down
5 changes: 3 additions & 2 deletions py/selenium/webdriver/common/actions/wheel_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from . import interaction
from .input_device import InputDevice
from typing import Union

from selenium.webdriver.remote.webelement import WebElement

from . import interaction
from .input_device import InputDevice


class ScrollOrigin:

Expand Down
15 changes: 7 additions & 8 deletions py/selenium/webdriver/common/bidi/cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,21 @@

# flake8: noqa

from trio_websocket import (
ConnectionClosed as WsConnectionClosed,
connect_websocket_url,
)
import trio
from collections import defaultdict
from contextlib import (contextmanager, asynccontextmanager)
from dataclasses import dataclass
import contextvars
import importlib
import itertools
import json
import logging
import pathlib
import typing
from collections import defaultdict
from contextlib import asynccontextmanager
from contextlib import contextmanager
from dataclasses import dataclass

import trio
from trio_websocket import ConnectionClosed as WsConnectionClosed
from trio_websocket import connect_websocket_url

logger = logging.getLogger('trio_cdp')
T = typing.TypeVar('T')
Expand Down
1 change: 0 additions & 1 deletion py/selenium/webdriver/common/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import json
import pkgutil

from contextlib import asynccontextmanager
from importlib import import_module

Expand Down
3 changes: 2 additions & 1 deletion py/selenium/webdriver/common/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
import typing
from abc import ABCMeta, abstractmethod
from abc import ABCMeta
from abc import abstractmethod

from selenium.common.exceptions import InvalidArgumentException
from selenium.webdriver.common.proxy import Proxy
Expand Down
13 changes: 9 additions & 4 deletions py/selenium/webdriver/common/print_page_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@


import sys
from typing import TYPE_CHECKING, List, Optional
from typing import TYPE_CHECKING
from typing import List
from typing import Optional

# necessary to support types for Python 3.7
if TYPE_CHECKING:
if sys.version_info >= (3, 8):
from typing import Literal, TypedDict
from typing import Literal
from typing import TypedDict
else:
from typing_extensions import Literal, TypedDict
from typing_extensions import Literal
from typing_extensions import TypedDict

Orientation = Literal['portrait', 'landscape']

Expand All @@ -47,7 +51,8 @@ class _PrintOpts(TypedDict, total=False):
shrinkToFit: bool
pageRanges: List[str]
else:
from typing import Any, Dict
from typing import Any
from typing import Dict

Orientation = str
_MarginOpts = _PageOpts = _PrintOpts = Dict[str, Any]
Expand Down
5 changes: 2 additions & 3 deletions py/selenium/webdriver/common/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from subprocess import DEVNULL

import errno
import os
import subprocess
from platform import system
from subprocess import DEVNULL
from subprocess import PIPE
from time import sleep

from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common import utils


_HAS_NATIVE_DEVNULL = True


Expand Down
1 change: 0 additions & 1 deletion py/selenium/webdriver/common/timeouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from typing import TYPE_CHECKING


if TYPE_CHECKING:
import sys
if sys.version_info >= (3, 8):
Expand Down
8 changes: 5 additions & 3 deletions py/selenium/webdriver/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
The Utils methods.
"""

from typing import Iterable, List, Optional, Union

import socket
from typing import Iterable
from typing import List
from typing import Optional
from typing import Union

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


_is_connectable_exceptions = (socket.error, ConnectionResetError)


Expand Down
6 changes: 3 additions & 3 deletions py/selenium/webdriver/common/virtual_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
# under the License.

import functools

from base64 import urlsafe_b64encode, urlsafe_b64decode
from enum import Enum
import typing
from base64 import urlsafe_b64decode
from base64 import urlsafe_b64encode
from enum import Enum


class Protocol(Enum):
Expand Down
Loading

0 comments on commit 3167e93

Please sign in to comment.