Skip to content

Commit

Permalink
* UP
Browse files Browse the repository at this point in the history
  • Loading branch information
bandophahita committed Feb 7, 2024
1 parent 47a2fb5 commit 4381e96
Show file tree
Hide file tree
Showing 32 changed files with 152 additions and 159 deletions.
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ select = [
"T10", # flake8-debugger
"T20", # flake8-print
"TCH", # flake8-type-checking
# "TRY", # tryceratops
# "UP", # python upgrade
"TRY", # tryceratops
"UP", # python upgrade
"W", # pycodestyle warning
# "YTT", # flake8-2020

Expand All @@ -173,6 +173,7 @@ extend-safe-fixes = [
"D200", "D205", "D415",
"PT003", "PT006", "PT018",
"RET504",
"UP007",
]

[tool.ruff.lint.per-file-ignores]
Expand Down
14 changes: 7 additions & 7 deletions screenpy_selenium/abilities/browse_the_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

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

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

Expand Down Expand Up @@ -35,22 +35,22 @@ class BrowseTheWeb:
browser: WebDriver

@classmethod
def using_chrome(cls: Type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
def using_chrome(cls: type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
"""Create and use a default Chrome Selenium webdriver instance."""
return cls.using(browser=Chrome())

@classmethod
def using_firefox(cls: Type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
def using_firefox(cls: type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
"""Create and use a default Firefox Selenium webdriver instance."""
return cls.using(browser=Firefox())

@classmethod
def using_safari(cls: Type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
def using_safari(cls: type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
"""Create and use a default Safari Selenium webdriver instance."""
return cls.using(browser=Safari())

@classmethod
def using_ios(cls: Type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
def using_ios(cls: type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
"""
Create and use a default Remote driver instance.
Expand Down Expand Up @@ -83,7 +83,7 @@ def using_ios(cls: Type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
return cls.using(browser=Remote(hub_url, IOS_CAPABILITIES))

@classmethod
def using_android(cls: Type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
def using_android(cls: type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
"""
Create and use a default Remote driver instance.
Expand Down Expand Up @@ -116,7 +116,7 @@ def using_android(cls: Type[SelfBrowseTheWeb]) -> SelfBrowseTheWeb:
return cls.using(browser=Remote(hub_url, ANDROID_CAPABILITIES))

@classmethod
def using(cls: Type[SelfBrowseTheWeb], browser: WebDriver) -> SelfBrowseTheWeb:
def using(cls: type[SelfBrowseTheWeb], browser: WebDriver) -> SelfBrowseTheWeb:
"""Provide an already-set-up WebDriver to use to browse the web."""
return cls(browser=browser)

Expand Down
8 changes: 4 additions & 4 deletions screenpy_selenium/actions/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

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

from screenpy.exceptions import DeliveryError
from screenpy.pacing import beat
Expand All @@ -28,7 +28,7 @@ class Clear:
"""

@classmethod
def the_text_from_the(cls: Type[SelfClear], target: Target) -> SelfClear:
def the_text_from_the(cls: type[SelfClear], target: Target) -> SelfClear:
"""
Specify the Target from which to clear the text.
Expand All @@ -39,13 +39,13 @@ def the_text_from_the(cls: Type[SelfClear], target: Target) -> SelfClear:
return cls(target=target)

@classmethod
def the_text_from(cls: Type[SelfClear], target: Target) -> SelfClear:
def the_text_from(cls: type[SelfClear], target: Target) -> SelfClear:
"""Alias for :meth:`~screenpy_selenium.actions.Clear.the_text_from_the`."""
return cls.the_text_from_the(target=target)

@classmethod
def the_text_from_the_first_of_the(
cls: Type[SelfClear], target: Target
cls: type[SelfClear], target: Target
) -> SelfClear:
"""Alias for :meth:`~screenpy_selenium.actions.Clear.the_text_from_the`."""
return cls.the_text_from_the(target=target)
Expand Down
10 changes: 5 additions & 5 deletions screenpy_selenium/actions/click.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

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

from screenpy.exceptions import DeliveryError, UnableToAct
from screenpy.pacing import beat
Expand Down Expand Up @@ -33,7 +33,7 @@ class Click:
"""

@classmethod
def on_the(cls: Type[SelfClick], target: Target) -> SelfClick:
def on_the(cls: type[SelfClick], target: Target) -> SelfClick:
"""
Target the element to click on.
Expand All @@ -44,12 +44,12 @@ def on_the(cls: Type[SelfClick], target: Target) -> SelfClick:
return cls(target=target)

@classmethod
def on(cls: Type[SelfClick], target: Target) -> SelfClick:
def on(cls: type[SelfClick], target: Target) -> SelfClick:
"""Alias for :meth:`~screenpy_selenium.actions.Click.on_the`."""
return cls.on_the(target=target)

@classmethod
def on_the_first_of_the(cls: Type[SelfClick], target: Target) -> SelfClick:
def on_the_first_of_the(cls: type[SelfClick], target: Target) -> SelfClick:
"""Alias for :meth:`~screenpy_selenium.actions.Click.on_the`."""
return cls.on_the(target=target)

Expand Down Expand Up @@ -90,6 +90,6 @@ def add_to_chain(

the_chain.click(on_element=the_element)

def __init__(self: SelfClick, target: Optional[Target] = None) -> None:
def __init__(self: SelfClick, target: Target | None = None) -> None:
self.target = target
self.description = f" on the {target}" if target is not None else ""
12 changes: 6 additions & 6 deletions screenpy_selenium/actions/double_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

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

from screenpy.pacing import beat
from selenium.webdriver.common.action_chains import ActionChains
Expand Down Expand Up @@ -30,10 +30,10 @@ class DoubleClick:
the_actor.attempts_to(Chain(DoubleClick()))
"""

target: Optional[Target]
target: Target | None

@classmethod
def on_the(cls: Type[SelfDoubleClick], target: Target) -> SelfDoubleClick:
def on_the(cls: type[SelfDoubleClick], target: Target) -> SelfDoubleClick:
"""
Target the element to double-click on.
Expand All @@ -44,13 +44,13 @@ def on_the(cls: Type[SelfDoubleClick], target: Target) -> SelfDoubleClick:
return cls(target=target)

@classmethod
def on(cls: Type[SelfDoubleClick], target: Target) -> SelfDoubleClick:
def on(cls: type[SelfDoubleClick], target: Target) -> SelfDoubleClick:
"""Alias for :meth:`~screenpy_selenium.actions.DoubleClick.on_the`."""
return cls.on_the(target=target)

@classmethod
def on_the_first_of_the(
cls: Type[SelfDoubleClick], target: Target
cls: type[SelfDoubleClick], target: Target
) -> SelfDoubleClick:
"""Alias for :meth:`~screenpy_selenium.actions.DoubleClick.on_the`."""
return cls.on_the(target=target)
Expand Down Expand Up @@ -85,6 +85,6 @@ def add_to_chain(
"""Add the DoubleClick Action to a Chain of Actions."""
self._add_action_to_chain(the_actor, the_chain)

def __init__(self: SelfDoubleClick, target: Optional[Target] = None) -> None:
def __init__(self: SelfDoubleClick, target: Target | None = None) -> None:
self.target = target
self.description = f" on the {target}" if target is not None else ""
14 changes: 7 additions & 7 deletions screenpy_selenium/actions/enter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

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

from screenpy.exceptions import DeliveryError, UnableToAct
from screenpy.pacing import aside, beat
Expand Down Expand Up @@ -33,13 +33,13 @@ class Enter:
)
"""

target: Optional[Target]
following_keys: List[str]
target: Target | None
following_keys: list[str]
text: str
text_to_log: str

@classmethod
def the_text(cls: Type[SelfEnter], text: str) -> SelfEnter:
def the_text(cls: type[SelfEnter], text: str) -> SelfEnter:
"""Provide the text to enter into the field.
Aliases:
Expand All @@ -48,12 +48,12 @@ def the_text(cls: Type[SelfEnter], text: str) -> SelfEnter:
return cls(text=text)

@classmethod
def the_keys(cls: Type[SelfEnter], text: str) -> SelfEnter:
def the_keys(cls: type[SelfEnter], text: str) -> SelfEnter:
"""Alias for :meth:`~screenpy_selenium.actions.Enter.the_text`."""
return cls.the_text(text=text)

@classmethod
def the_secret(cls: Type[SelfEnter], text: str) -> SelfEnter:
def the_secret(cls: type[SelfEnter], text: str) -> SelfEnter:
"""
Provide the text to enter into the field, but mask it in logging.
Expand All @@ -65,7 +65,7 @@ def the_secret(cls: Type[SelfEnter], text: str) -> SelfEnter:
return cls(text=text, mask=True)

@classmethod
def the_password(cls: Type[SelfEnter], text: str) -> SelfEnter:
def the_password(cls: type[SelfEnter], text: str) -> SelfEnter:
"""Alias for :meth:`~screenpy_selenium.actions.Enter.the_secret`."""
return cls.the_secret(text=text)

Expand Down
6 changes: 3 additions & 3 deletions screenpy_selenium/actions/enter_2fa_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

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

from screenpy.pacing import beat
from screenpy_pyotp.abilities import AuthenticateWith2FA
Expand Down Expand Up @@ -31,7 +31,7 @@ class Enter2FAToken:
"""

@classmethod
def into_the(cls: Type[SelfEnter2FAToken], target: Target) -> SelfEnter2FAToken:
def into_the(cls: type[SelfEnter2FAToken], target: Target) -> SelfEnter2FAToken:
"""
Target the element into which to enter the 2FA token.
Expand All @@ -41,7 +41,7 @@ def into_the(cls: Type[SelfEnter2FAToken], target: Target) -> SelfEnter2FAToken:
return cls(target)

@classmethod
def into(cls: Type[SelfEnter2FAToken], target: Target) -> SelfEnter2FAToken:
def into(cls: type[SelfEnter2FAToken], target: Target) -> SelfEnter2FAToken:
"""Alias for :meth:`~screenpy_selenium.actions.Enter2FAToken.into_the`."""
return cls.into_the(target=target)

Expand Down
14 changes: 6 additions & 8 deletions screenpy_selenium/actions/hold_down.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

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

from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat
Expand Down Expand Up @@ -41,13 +41,13 @@ class HoldDown:
)
"""

target: Optional[Target]
key: Optional[str]
target: Target | None
key: str | None
lmb: bool
description: str

@classmethod
def command_or_control_key(cls: Type[SelfHoldDown]) -> SelfHoldDown:
def command_or_control_key(cls: type[SelfHoldDown]) -> SelfHoldDown:
"""
A convenience method for supporting multiple operating systems.
Expand All @@ -59,7 +59,7 @@ def command_or_control_key(cls: Type[SelfHoldDown]) -> SelfHoldDown:
return cls(Keys.CONTROL)

@classmethod
def left_mouse_button(cls: Type[SelfHoldDown]) -> SelfHoldDown:
def left_mouse_button(cls: type[SelfHoldDown]) -> SelfHoldDown:
"""Hold down the left mouse button."""
return cls(lmb=True)

Expand Down Expand Up @@ -88,9 +88,7 @@ def add_to_chain(
msg = "HoldDown must be told what to hold down."
raise UnableToAct(msg)

def __init__(
self: SelfHoldDown, key: Optional[str] = None, lmb: bool = False
) -> None:
def __init__(self: SelfHoldDown, key: str | None = None, lmb: bool = False) -> None:
self.key = key
self.lmb = lmb
self.target = None
Expand Down
22 changes: 11 additions & 11 deletions screenpy_selenium/actions/move_mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

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

from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat
Expand Down Expand Up @@ -43,12 +43,12 @@ class MoveMouse:
)
"""

offset: Optional[Tuple[int, int]]
target: Optional[Target]
offset: tuple[int, int] | None
target: Target | None
description: str

@classmethod
def to_the(cls: Type[SelfMoveMouse], target: Target) -> SelfMoveMouse:
def to_the(cls: type[SelfMoveMouse], target: Target) -> SelfMoveMouse:
"""
Target an element to move the mouse to.
Expand All @@ -61,30 +61,30 @@ def to_the(cls: Type[SelfMoveMouse], target: Target) -> SelfMoveMouse:
return cls(target=target, description=f"to the {target}")

@classmethod
def on_the(cls: Type[SelfMoveMouse], target: Target) -> SelfMoveMouse:
def on_the(cls: type[SelfMoveMouse], target: Target) -> SelfMoveMouse:
"""Alias for :meth:`~screenpy_selenium.actions.MoveMouse.to_the`."""
return cls.to_the(target=target)

@classmethod
def over_the(cls: Type[SelfMoveMouse], target: Target) -> SelfMoveMouse:
def over_the(cls: type[SelfMoveMouse], target: Target) -> SelfMoveMouse:
"""Alias for :meth:`~screenpy_selenium.actions.MoveMouse.to_the`."""
return cls.to_the(target=target)

@classmethod
def over_the_first_of_the(
cls: Type[SelfMoveMouse], target: Target
cls: type[SelfMoveMouse], target: Target
) -> SelfMoveMouse:
"""Alias for :meth:`~screenpy_selenium.actions.MoveMouse.to_the`."""
return cls.to_the(target=target)

@classmethod
def to_the_first_of_the(cls: Type[SelfMoveMouse], target: Target) -> SelfMoveMouse:
def to_the_first_of_the(cls: type[SelfMoveMouse], target: Target) -> SelfMoveMouse:
"""Alias for :meth:`~screenpy_selenium.actions.MoveMouse.to_the`."""
return cls.to_the(target=target)

@classmethod
def by_offset(
cls: Type[SelfMoveMouse], x_offset: int, y_offset: int
cls: type[SelfMoveMouse], x_offset: int, y_offset: int
) -> SelfMoveMouse:
"""Specify the offset by which to move the mouse."""
return cls(
Expand Down Expand Up @@ -138,8 +138,8 @@ def add_to_chain(

def __init__(
self: SelfMoveMouse,
offset: Optional[Tuple[int, int]] = None,
target: Optional[Target] = None,
offset: tuple[int, int] | None = None,
target: Target | None = None,
description: str = "",
) -> None:
self.offset = offset
Expand Down
Loading

0 comments on commit 4381e96

Please sign in to comment.