Skip to content

Commit

Permalink
updated ruff configuration to move all possible imports into TYPE_CHE…
Browse files Browse the repository at this point in the history
…CKING
  • Loading branch information
bandophahita committed Feb 14, 2024
1 parent f21539a commit ca41542
Show file tree
Hide file tree
Showing 27 changed files with 47 additions and 70 deletions.
18 changes: 5 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@ local_screenpy:
black-check:
black --check .

black:
black-fix:
black .

isort-check:
isort . --check

isort:
isort .

ruff:
ruff-check:
ruff check .

ruff-fix:
Expand All @@ -41,12 +35,10 @@ ruff-fix:
mypy:
mypy .

lint: isort-check ruff mypy

.PHONY: black-check black isort-check isort ruff ruff-fix mypy lint
.PHONY: black-check black-fix ruff-check ruff-fix mypy

pre-check-in: black-check lint
pre-check-in: black-check ruff-check mypy

pre-check-in-fix: black isort ruff-fix mypy
pre-check-in-fix: black-fix ruff-fix mypy

.PHONY: pre-check-in pre-check-in-fix
23 changes: 4 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ importlib_metadata = {version = "*", python = "3.8.*"}
# convenience packages for development of screenpy only
black = {version = "*", optional = true}
coverage = {version = "*", optional = true}
isort = {version = "*", optional = true}
mypy = {version = "*", optional = true}
pre-commit = {version = "*", optional = true}
pytest = {version = "*", optional = true}
Expand All @@ -86,7 +85,6 @@ dev = [
dev_all = [
"black",
"coverage",
"isort",
"mypy",
"pre-commit",
"pytest",
Expand Down Expand Up @@ -166,14 +164,11 @@ extend-safe-fixes = [
"EM101",
"EM102",
"TCH001", "TCH002", "TCH003", "TCH004",
# "SIM108"
# maybe?
# "F841",
"C419",
"D200", "D205", "D415",
"PT003", "PT006", "PT018",
"RET504",
"UP007",
"UP006", "UP007",
]

[tool.ruff.lint.per-file-ignores]
Expand All @@ -182,13 +177,10 @@ extend-safe-fixes = [
"FBT", # using a boolean as a test object is useful!
"PLR", # likewise using specific numbers and strings in tests.
]
"tests/test_pacing.py" = [
"FA100", # we are purposely testing pacing without future annotations.
]

[tool.ruff.lint.isort]
combine-as-imports = true
split-on-trailing-comma = true
split-on-trailing-comma = false
known-first-party = ["screenpy_selenium", "tests"]


Expand All @@ -204,12 +196,5 @@ ignore-overlong-task-comments = true
convention = "google"


[tool.isort]
line_length = 88
multi_line_output = 3
include_trailing_comma = true
use_parentheses = true
combine_as_imports = true

skip = [".idea", ".tox", "docs"]
src_paths = ["screenpy_selenium","tests"]
[tool.ruff.lint.flake8-type-checking]
strict = true
2 changes: 1 addition & 1 deletion screenpy_selenium/abilities/browse_the_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from typing import TYPE_CHECKING

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

from ..exceptions import BrowsingError

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

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

Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from screenpy.exceptions import DeliveryError
from screenpy.pacing import beat
from selenium.common.exceptions import WebDriverException
from typing_extensions import Self

if TYPE_CHECKING:
from screenpy.actor import Actor
from typing_extensions import Self

from ..target import Target

Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/click.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from screenpy.exceptions import DeliveryError, UnableToAct
from screenpy.pacing import beat
from selenium.common.exceptions import WebDriverException
from typing_extensions import Self

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

from ..target import Target

Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/double_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from screenpy.pacing import beat
from selenium.webdriver.common.action_chains import ActionChains
from typing_extensions import Self

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy.actor import Actor
from typing_extensions import Self

from ..target import Target

Expand Down
6 changes: 2 additions & 4 deletions screenpy_selenium/actions/enter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
from screenpy.exceptions import DeliveryError, UnableToAct
from screenpy.pacing import aside, beat
from selenium.common.exceptions import WebDriverException
from typing_extensions import Self

from ..common import pos_args_deprecated
from ..speech_tools import KEY_NAMES

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

from ..target import Target

Expand Down Expand Up @@ -151,9 +151,7 @@ def add_to_chain(self, the_actor: Actor, the_chain: ActionChains) -> None:
send_keys(key)

@pos_args_deprecated("mask")
def __init__(
self, text: str, mask: bool = False # noqa: FBT001, FBT002
) -> None:
def __init__(self, text: str, mask: bool = False) -> None: # noqa: FBT001, FBT002
self.text = text
self.target = None
self.following_keys = []
Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/enter_2fa_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

from screenpy.pacing import beat
from screenpy_pyotp.abilities import AuthenticateWith2FA
from typing_extensions import Self

from .enter import Enter

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

from ..target import Target

Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/hold_down.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat
from selenium.webdriver.common.keys import Keys
from typing_extensions import Self

from ..common import pos_args_deprecated
from ..speech_tools import KEY_NAMES

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

from ..target import Target

Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/move_mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat
from selenium.webdriver.common.action_chains import ActionChains
from typing_extensions import Self

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy.actor import Actor
from typing_extensions import Self

from ..target import Target

Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from typing import TYPE_CHECKING

from screenpy.pacing import beat
from typing_extensions import Self

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy import Actor
from typing_extensions import Self


class Open:
Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat
from selenium.webdriver.common.keys import Keys
from typing_extensions import Self

from ..common import pos_args_deprecated
from ..speech_tools import KEY_NAMES

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


class Release:
Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/respond_to_the_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from typing import TYPE_CHECKING

from screenpy.pacing import aside, beat
from typing_extensions import Self

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy.actor import Actor
from typing_extensions import Self


class RespondToThePrompt:
Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/right_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from screenpy.pacing import beat
from selenium.webdriver.common.action_chains import ActionChains
from typing_extensions import Self

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy import Actor
from typing_extensions import Self

from ..target import Target

Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/save_console_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

from screenpy.actions import AttachTheFile
from screenpy.pacing import beat
from typing_extensions import Self

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy import Actor
from typing_extensions import Self


class SaveConsoleLog:
Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/save_screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

from screenpy.actions import AttachTheFile
from screenpy.pacing import beat
from typing_extensions import Self

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy import Actor
from typing_extensions import Self


class SaveScreenshot:
Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from screenpy.pacing import beat
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.support.ui import Select as SeleniumSelect
from typing_extensions import Self

if TYPE_CHECKING:
from screenpy import Actor
from typing_extensions import Self

from ..target import Target

Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/actions/switch_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from typing import TYPE_CHECKING

from screenpy.pacing import beat
from typing_extensions import Self

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy.actor import Actor
from typing_extensions import Self

from ..target import Target

Expand Down
6 changes: 4 additions & 2 deletions screenpy_selenium/actions/wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

from typing import TYPE_CHECKING, Any, Callable, Iterable

from screenpy import Actor, settings
from screenpy import settings
from screenpy.exceptions import DeliveryError
from screenpy.pacing import beat
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from typing_extensions import Self

from ..abilities import BrowseTheWeb

if TYPE_CHECKING:
from screenpy import Actor
from typing_extensions import Self

from ..target import Target


Expand Down
4 changes: 2 additions & 2 deletions screenpy_selenium/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from functools import wraps
from typing import TYPE_CHECKING, Callable, TypeVar

from typing_extensions import ParamSpec

if TYPE_CHECKING:
from typing_extensions import ParamSpec

P = ParamSpec("P")
T = TypeVar("T")
Function = Callable[P, T]
Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/questions/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from typing import TYPE_CHECKING

from screenpy.pacing import beat
from typing_extensions import Self

if TYPE_CHECKING:
from screenpy import Actor
from selenium.webdriver.remote.webdriver import WebElement
from typing_extensions import Self

from ..target import Target

Expand Down
2 changes: 1 addition & 1 deletion screenpy_selenium/questions/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from typing import TYPE_CHECKING

from screenpy.pacing import beat
from typing_extensions import Self

if TYPE_CHECKING:
from screenpy import Actor
from typing_extensions import Self

from ..target import Target

Expand Down
Loading

0 comments on commit ca41542

Please sign in to comment.