Skip to content

Commit

Permalink
* TCH
Browse files Browse the repository at this point in the history
  • Loading branch information
bandophahita committed Jan 11, 2024
1 parent b0900f4 commit 7b4dd75
Show file tree
Hide file tree
Showing 49 changed files with 250 additions and 112 deletions.
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ select = [
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RET", # flake8-return
# "RSE", # flake8-raise
# "RUF", # ruff specific
# "SIM", # flake8-simplify
# "T10", # flake8-debugger
# "T20", # flake8-print
# "TCH", # flake8-type-checking
"RSE", # flake8-raise
"RUF", # ruff specific
"SIM", # flake8-simplify
"T10", # flake8-debugger
"T20", # flake8-print
"TCH", # flake8-type-checking
# "TRY", # tryceratops
# "UP", # python upgrade
"W", # pycodestyle warning
Expand All @@ -164,7 +164,7 @@ exclude = [
extend-safe-fixes = [
"EM101",
"EM102",
# "TCH001", "TCH002", "TCH003", "TCH004",
"TCH001", "TCH002", "TCH003", "TCH004",
# "SIM108"
# maybe?
# "F841",
Expand Down
6 changes: 4 additions & 2 deletions screenpy_selenium/abilities/browse_the_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
from __future__ import annotations

import os
from typing import Type, TypeVar
from typing import TYPE_CHECKING, Type, TypeVar

from selenium.webdriver import Chrome, Firefox, Remote, Safari
from selenium.webdriver.remote.webdriver import WebDriver

from ..exceptions import BrowsingError

if TYPE_CHECKING:
from selenium.webdriver.remote.webdriver import WebDriver

DEFAULT_APPIUM_HUB_URL = "http://localhost:4723/wd/hub"


Expand Down
6 changes: 5 additions & 1 deletion screenpy_selenium/actions/accept_alert.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""Accept a javascript alert."""
from __future__ import annotations

from screenpy.actor import Actor
from typing import TYPE_CHECKING

from screenpy.pacing import aside, beat

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy.actor import Actor


class AcceptAlert:
"""Accept an alert!
Expand Down
6 changes: 5 additions & 1 deletion screenpy_selenium/actions/chain.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
"""A meta-Action to group a series of chainable Actions together."""
from __future__ import annotations

from screenpy.actor import Actor
from typing import TYPE_CHECKING

from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat
from selenium.webdriver.common.action_chains import ActionChains

from ..abilities import BrowseTheWeb
from ..protocols import Chainable

if TYPE_CHECKING:
from screenpy.actor import Actor


class Chain:
"""Group a series of chainable Actions together.
Expand Down
8 changes: 5 additions & 3 deletions screenpy_selenium/actions/clear.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"""Clear text from an input."""
from __future__ import annotations

from typing import Type, TypeVar
from typing import TYPE_CHECKING, Type, TypeVar

from screenpy.actor import Actor
from screenpy.exceptions import DeliveryError
from screenpy.pacing import beat
from selenium.common.exceptions import WebDriverException

from ..target import Target
if TYPE_CHECKING:
from screenpy.actor import Actor

from ..target import Target

SelfClear = TypeVar("SelfClear", bound="Clear")

Expand Down
10 changes: 6 additions & 4 deletions screenpy_selenium/actions/click.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
"""Click on an element."""
from __future__ import annotations

from typing import Optional, Type, TypeVar
from typing import TYPE_CHECKING, Optional, Type, TypeVar

from screenpy.actor import Actor
from screenpy.exceptions import DeliveryError, UnableToAct
from screenpy.pacing import beat
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common.action_chains import ActionChains

from ..target import Target
if TYPE_CHECKING:
from screenpy.actor import Actor
from selenium.webdriver.common.action_chains import ActionChains

from ..target import Target

SelfClick = TypeVar("SelfClick", bound="Click")

Expand Down
6 changes: 5 additions & 1 deletion screenpy_selenium/actions/dismiss_alert.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""Dismiss a javascript alert."""
from __future__ import annotations

from screenpy.actor import Actor
from typing import TYPE_CHECKING

from screenpy.pacing import aside, beat

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy.actor import Actor


class DismissAlert:
"""Dismiss an alert.
Expand Down
9 changes: 6 additions & 3 deletions screenpy_selenium/actions/double_click.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
"""Double-click on an element, or wherever the cursor currently is."""
from __future__ import annotations

from typing import Optional, Type, TypeVar
from typing import TYPE_CHECKING, Optional, Type, TypeVar

from screenpy.actor import Actor
from screenpy.pacing import beat
from selenium.webdriver.common.action_chains import ActionChains

from ..abilities import BrowseTheWeb
from ..target import Target

if TYPE_CHECKING:
from screenpy.actor import Actor

from ..target import Target

SelfDoubleClick = TypeVar("SelfDoubleClick", bound="DoubleClick")

Expand Down
11 changes: 7 additions & 4 deletions screenpy_selenium/actions/enter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
from __future__ import annotations

from functools import partial
from typing import List, Optional, Type, TypeVar
from typing import TYPE_CHECKING, List, Optional, Type, TypeVar

from screenpy import Actor
from screenpy.exceptions import DeliveryError, UnableToAct
from screenpy.pacing import aside, beat
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common.action_chains import ActionChains

from ..speech_tools import KEY_NAMES
from ..target import Target

if TYPE_CHECKING:
from screenpy import Actor
from selenium.webdriver.common.action_chains import ActionChains

from ..target import Target

SelfEnter = TypeVar("SelfEnter", bound="Enter")

Expand Down
11 changes: 7 additions & 4 deletions screenpy_selenium/actions/enter_2fa_token.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
"""Enter a 2-factor authentication code into a text field."""
from __future__ import annotations

from typing import Type, TypeVar
from typing import TYPE_CHECKING, Type, TypeVar

from screenpy.actor import Actor
from screenpy.pacing import beat
from screenpy_pyotp.abilities import AuthenticateWith2FA
from selenium.webdriver.common.action_chains import ActionChains

from ..target import Target
from .enter import Enter

if TYPE_CHECKING:
from screenpy.actor import Actor
from selenium.webdriver.common.action_chains import ActionChains

from ..target import Target

SelfEnter2FAToken = TypeVar("SelfEnter2FAToken", bound="Enter2FAToken")


Expand Down
6 changes: 5 additions & 1 deletion screenpy_selenium/actions/go_back.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""Press the browser back button."""
from __future__ import annotations

from screenpy.actor import Actor
from typing import TYPE_CHECKING

from screenpy.pacing import beat

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy.actor import Actor


class GoBack:
"""Press the browser back button.
Expand Down
6 changes: 5 additions & 1 deletion screenpy_selenium/actions/go_forward.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""Press the browser forward button."""
from __future__ import annotations

from screenpy.actor import Actor
from typing import TYPE_CHECKING

from screenpy.pacing import beat

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy.actor import Actor


class GoForward:
"""Press the browser forward button.
Expand Down
11 changes: 7 additions & 4 deletions screenpy_selenium/actions/hold_down.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
from __future__ import annotations

import platform
from typing import Optional, Type, TypeVar
from typing import TYPE_CHECKING, Optional, Type, TypeVar

from screenpy import Actor
from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

from ..speech_tools import KEY_NAMES
from ..target import Target

if TYPE_CHECKING:
from screenpy import Actor
from selenium.webdriver.common.action_chains import ActionChains

from ..target import Target

SelfHoldDown = TypeVar("SelfHoldDown", bound="HoldDown")

Expand Down
9 changes: 6 additions & 3 deletions screenpy_selenium/actions/move_mouse.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
"""Move the mouse to a specific element, or by an offset."""
from __future__ import annotations

from typing import Optional, Tuple, Type, TypeVar
from typing import TYPE_CHECKING, Optional, Tuple, Type, TypeVar

from screenpy.actor import Actor
from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat
from selenium.webdriver.common.action_chains import ActionChains

from ..abilities import BrowseTheWeb
from ..target import Target

if TYPE_CHECKING:
from screenpy.actor import Actor

from ..target import Target

SelfMoveMouse = TypeVar("SelfMoveMouse", bound="MoveMouse")

Expand Down
6 changes: 4 additions & 2 deletions screenpy_selenium/actions/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
from __future__ import annotations

import os
from typing import Type, TypeVar, Union
from typing import TYPE_CHECKING, Type, TypeVar, Union

from screenpy import Actor
from screenpy.pacing import beat

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy import Actor

SelfOpen = TypeVar("SelfOpen", bound="Open")


Expand Down
8 changes: 6 additions & 2 deletions screenpy_selenium/actions/pause.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
"""Pause just like in ScreenPy, but also be able to do it in a Chain!"""
from __future__ import annotations

from screenpy import Actor
from typing import TYPE_CHECKING

from screenpy.actions import Pause as BasePause
from screenpy.pacing import beat
from selenium.webdriver.common.action_chains import ActionChains

if TYPE_CHECKING:
from screenpy import Actor
from selenium.webdriver.common.action_chains import ActionChains


class Pause(BasePause):
Expand Down
6 changes: 5 additions & 1 deletion screenpy_selenium/actions/refresh_page.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""Refresh the browser page."""
from __future__ import annotations

from screenpy import Actor
from typing import TYPE_CHECKING

from screenpy.pacing import beat

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy import Actor


class RefreshPage:
"""Refresh the browser page!
Expand Down
8 changes: 5 additions & 3 deletions screenpy_selenium/actions/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
from __future__ import annotations

import platform
from typing import Optional, Type, TypeVar
from typing import TYPE_CHECKING, Optional, Type, TypeVar

from screenpy import Actor
from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

from ..speech_tools import KEY_NAMES

if TYPE_CHECKING:
from screenpy import Actor
from selenium.webdriver.common.action_chains import ActionChains

SelfRelease = TypeVar("SelfRelease", bound="Release")


Expand Down
6 changes: 4 additions & 2 deletions screenpy_selenium/actions/respond_to_the_prompt.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Respond to a prompt."""
from __future__ import annotations

from typing import Type, TypeVar
from typing import TYPE_CHECKING, Type, TypeVar

from screenpy.actor import Actor
from screenpy.pacing import aside, beat

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy.actor import Actor

SelfRespondToThePrompt = TypeVar("SelfRespondToThePrompt", bound="RespondToThePrompt")


Expand Down
Loading

0 comments on commit 7b4dd75

Please sign in to comment.