Skip to content

Commit 3167e93

Browse files
authored
[py]: new tox recipe for isort in non diff only mode (#11005)
* [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/`
1 parent 316f973 commit 3167e93

File tree

99 files changed

+308
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+308
-253
lines changed

py/selenium/common/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
from .exceptions import UnknownMethodException
5050
from .exceptions import WebDriverException
5151

52-
5352
__all__ = ["WebDriverException",
5453
"InvalidSwitchToTargetException",
5554
"NoSuchFrameException",

py/selenium/common/exceptions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
Exceptions that may happen in all the webdriver code.
2020
"""
2121

22-
from typing import Optional, Sequence
22+
from typing import Optional
23+
from typing import Sequence
2324

2425

2526
class WebDriverException(Exception):

py/selenium/types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@
1919

2020
import typing
2121

22-
2322
AnyKey = typing.Union[str, int, float]
2423
WaitExcTypes = typing.Iterable[typing.Type[Exception]]

py/selenium/webdriver/__init__.py

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

18-
from .firefox.webdriver import WebDriver as Firefox # noqa
18+
from .chrome.options import Options as ChromeOptions # noqa
19+
from .chrome.webdriver import WebDriver as Chrome # noqa
20+
from .common.action_chains import ActionChains # noqa
21+
from .common.desired_capabilities import DesiredCapabilities # noqa
22+
from .common.keys import Keys # noqa
23+
from .common.proxy import Proxy # noqa
24+
from .edge.options import Options as EdgeOptions # noqa
25+
from .edge.webdriver import WebDriver as ChromiumEdge # noqa
26+
from .edge.webdriver import WebDriver as Edge # noqa
1927
from .firefox.firefox_profile import FirefoxProfile # noqa
2028
from .firefox.options import Options as FirefoxOptions # noqa
21-
from .chrome.webdriver import WebDriver as Chrome # noqa
22-
from .chrome.options import Options as ChromeOptions # noqa
23-
from .ie.webdriver import WebDriver as Ie # noqa
29+
from .firefox.webdriver import WebDriver as Firefox # noqa
2430
from .ie.options import Options as IeOptions # noqa
25-
from .edge.webdriver import WebDriver as Edge # noqa
26-
from .edge.webdriver import WebDriver as ChromiumEdge # noqa
27-
from .edge.options import Options as EdgeOptions # noqa
31+
from .ie.webdriver import WebDriver as Ie # noqa
32+
from .remote.webdriver import WebDriver as Remote # noqa
2833
from .safari.webdriver import WebDriver as Safari # noqa
29-
from .webkitgtk.webdriver import WebDriver as WebKitGTK # noqa
3034
from .webkitgtk.options import Options as WebKitGTKOptions # noqa
31-
from .wpewebkit.webdriver import WebDriver as WPEWebKit # noqa
35+
from .webkitgtk.webdriver import WebDriver as WebKitGTK # noqa
3236
from .wpewebkit.options import Options as WPEWebKitOptions # noqa
33-
from .remote.webdriver import WebDriver as Remote # noqa
34-
from .common.desired_capabilities import DesiredCapabilities # noqa
35-
from .common.action_chains import ActionChains # noqa
36-
from .common.proxy import Proxy # noqa
37-
from .common.keys import Keys # noqa
37+
from .wpewebkit.webdriver import WebDriver as WPEWebKit # noqa
3838

3939
__version__ = '4.5.0'
4040

py/selenium/webdriver/chrome/options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
from typing import Optional
19+
1820
from selenium.webdriver.chromium.options import ChromiumOptions
1921
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
20-
from typing import Optional
2122

2223

2324
class Options(ChromiumOptions):

py/selenium/webdriver/chrome/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# under the License.
1717

1818
from typing import List
19-
from selenium.webdriver.chromium import service
2019

20+
from selenium.webdriver.chromium import service
2121

2222
DEFAULT_EXECUTABLE_PATH = "chromedriver"
2323

py/selenium/webdriver/chrome/webdriver.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
import warnings
18+
1819
from selenium.webdriver.chromium.webdriver import ChromiumDriver
19-
from .options import Options
20-
from .service import DEFAULT_EXECUTABLE_PATH, Service
2120
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
2221

22+
from .options import Options
23+
from .service import DEFAULT_EXECUTABLE_PATH
24+
from .service import Service
25+
2326
DEFAULT_PORT = 0
2427
DEFAULT_SERVICE_LOG_PATH = None
2528
DEFAULT_KEEP_ALIVE = None

py/selenium/webdriver/chromium/options.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import base64
1919
import os
2020
import warnings
21-
from typing import List, Union, BinaryIO
21+
from typing import BinaryIO
22+
from typing import List
23+
from typing import Union
2224

2325
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
2426
from selenium.webdriver.common.options import ArgOptions

py/selenium/webdriver/chromium/service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717

1818
from typing import List
19+
1920
from selenium.webdriver.common import service
2021

2122

py/selenium/webdriver/chromium/webdriver.py

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

18-
from selenium.webdriver.common.options import BaseOptions
19-
from selenium.webdriver.common.service import Service
20-
from selenium.webdriver.edge.options import Options as EdgeOptions
21-
from selenium.webdriver.chrome.options import Options as ChromeOptions
2218
import warnings
2319

20+
from selenium.webdriver.chrome.options import Options as ChromeOptions
2421
from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection
22+
from selenium.webdriver.common.options import BaseOptions
23+
from selenium.webdriver.common.service import Service
24+
from selenium.webdriver.edge.options import Options as EdgeOptions
2525
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
2626

2727
DEFAULT_PORT = 0

py/selenium/webdriver/common/action_chains.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
"""
2121
import warnings
2222

23-
from .actions.wheel_input import ScrollOrigin
23+
from selenium.webdriver.remote.webelement import WebElement
2424

25-
from .utils import keys_to_typing
2625
from .actions.action_builder import ActionBuilder
27-
from selenium.webdriver.remote.webelement import WebElement
26+
from .actions.wheel_input import ScrollOrigin
27+
from .utils import keys_to_typing
2828

2929

3030
class ActionChains:

py/selenium/webdriver/common/actions/action_builder.py

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

18-
from typing import Union, List
18+
from typing import List
19+
from typing import Union
20+
1921
from selenium.webdriver.remote.command import Command
22+
2023
from . import interaction
2124
from .key_actions import KeyActions
2225
from .key_input import KeyInput
2326
from .pointer_actions import PointerActions
2427
from .pointer_input import PointerInput
25-
from .wheel_input import WheelInput
2628
from .wheel_actions import WheelActions
29+
from .wheel_input import WheelInput
2730

2831

2932
class ActionBuilder:

py/selenium/webdriver/common/actions/key_actions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
from .interaction import Interaction, KEY
18-
from .key_input import KeyInput
1917
from ..utils import keys_to_typing
18+
from .interaction import KEY
19+
from .interaction import Interaction
20+
from .key_input import KeyInput
2021

2122

2223
class KeyActions(Interaction):

py/selenium/webdriver/common/actions/key_input.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
from . import interaction
18-
1918
from .input_device import InputDevice
20-
from .interaction import (Interaction,
21-
Pause)
19+
from .interaction import Interaction
20+
from .interaction import Pause
2221

2322

2423
class KeyInput(InputDevice):

py/selenium/webdriver/common/actions/pointer_actions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717

1818
from selenium.webdriver.remote.webelement import WebElement
19+
1920
from . import interaction
2021
from .interaction import Interaction
2122
from .mouse_button import MouseButton

py/selenium/webdriver/common/actions/pointer_input.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919
from selenium.common.exceptions import InvalidArgumentException
2020
from selenium.webdriver.remote.webelement import WebElement
21+
2122
from .input_device import InputDevice
22-
from .interaction import POINTER, POINTER_KINDS
23+
from .interaction import POINTER
24+
from .interaction import POINTER_KINDS
2325

2426

2527
class PointerInput(InputDevice):

py/selenium/webdriver/common/actions/wheel_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
from .wheel_input import WheelInput
1817
from .interaction import Interaction
18+
from .wheel_input import WheelInput
1919

2020

2121
class WheelActions(Interaction):

py/selenium/webdriver/common/actions/wheel_input.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
from . import interaction
18-
from .input_device import InputDevice
1917
from typing import Union
2018

2119
from selenium.webdriver.remote.webelement import WebElement
2220

21+
from . import interaction
22+
from .input_device import InputDevice
23+
2324

2425
class ScrollOrigin:
2526

py/selenium/webdriver/common/bidi/cdp.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,21 @@
2424

2525
# flake8: noqa
2626

27-
from trio_websocket import (
28-
ConnectionClosed as WsConnectionClosed,
29-
connect_websocket_url,
30-
)
31-
import trio
32-
from collections import defaultdict
33-
from contextlib import (contextmanager, asynccontextmanager)
34-
from dataclasses import dataclass
3527
import contextvars
3628
import importlib
3729
import itertools
3830
import json
3931
import logging
4032
import pathlib
4133
import typing
34+
from collections import defaultdict
35+
from contextlib import asynccontextmanager
36+
from contextlib import contextmanager
37+
from dataclasses import dataclass
4238

39+
import trio
40+
from trio_websocket import ConnectionClosed as WsConnectionClosed
41+
from trio_websocket import connect_websocket_url
4342

4443
logger = logging.getLogger('trio_cdp')
4544
T = typing.TypeVar('T')

py/selenium/webdriver/common/log.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import json
1919
import pkgutil
20-
2120
from contextlib import asynccontextmanager
2221
from importlib import import_module
2322

py/selenium/webdriver/common/options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
import typing
18-
from abc import ABCMeta, abstractmethod
18+
from abc import ABCMeta
19+
from abc import abstractmethod
1920

2021
from selenium.common.exceptions import InvalidArgumentException
2122
from selenium.webdriver.common.proxy import Proxy

py/selenium/webdriver/common/print_page_options.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@
1717

1818

1919
import sys
20-
from typing import TYPE_CHECKING, List, Optional
20+
from typing import TYPE_CHECKING
21+
from typing import List
22+
from typing import Optional
2123

2224
# necessary to support types for Python 3.7
2325
if TYPE_CHECKING:
2426
if sys.version_info >= (3, 8):
25-
from typing import Literal, TypedDict
27+
from typing import Literal
28+
from typing import TypedDict
2629
else:
27-
from typing_extensions import Literal, TypedDict
30+
from typing_extensions import Literal
31+
from typing_extensions import TypedDict
2832

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

@@ -47,7 +51,8 @@ class _PrintOpts(TypedDict, total=False):
4751
shrinkToFit: bool
4852
pageRanges: List[str]
4953
else:
50-
from typing import Any, Dict
54+
from typing import Any
55+
from typing import Dict
5156

5257
Orientation = str
5358
_MarginOpts = _PageOpts = _PrintOpts = Dict[str, Any]

py/selenium/webdriver/common/service.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
from subprocess import DEVNULL
18-
1917
import errno
2018
import os
2119
import subprocess
2220
from platform import system
21+
from subprocess import DEVNULL
2322
from subprocess import PIPE
2423
from time import sleep
24+
2525
from selenium.common.exceptions import WebDriverException
2626
from selenium.webdriver.common import utils
2727

28-
2928
_HAS_NATIVE_DEVNULL = True
3029

3130

py/selenium/webdriver/common/timeouts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
from typing import TYPE_CHECKING
2020

21-
2221
if TYPE_CHECKING:
2322
import sys
2423
if sys.version_info >= (3, 8):

py/selenium/webdriver/common/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
The Utils methods.
2020
"""
2121

22-
from typing import Iterable, List, Optional, Union
23-
2422
import socket
23+
from typing import Iterable
24+
from typing import List
25+
from typing import Optional
26+
from typing import Union
27+
2528
from selenium.types import AnyKey
2629
from selenium.webdriver.common.keys import Keys
2730

28-
2931
_is_connectable_exceptions = (socket.error, ConnectionResetError)
3032

3133

py/selenium/webdriver/common/virtual_authenticator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
# under the License.
1717

1818
import functools
19-
20-
from base64 import urlsafe_b64encode, urlsafe_b64decode
21-
from enum import Enum
2219
import typing
20+
from base64 import urlsafe_b64decode
21+
from base64 import urlsafe_b64encode
22+
from enum import Enum
2323

2424

2525
class Protocol(Enum):

0 commit comments

Comments
 (0)