diff --git a/Makefile b/Makefile index 2054540..b47e564 100644 --- a/Makefile +++ b/Makefile @@ -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: @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 9cf0ac3..16d87d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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} @@ -86,7 +85,6 @@ dev = [ dev_all = [ "black", "coverage", - "isort", "mypy", "pre-commit", "pytest", @@ -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] @@ -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"] @@ -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 diff --git a/screenpy_selenium/abilities/browse_the_web.py b/screenpy_selenium/abilities/browse_the_web.py index a5f9237..43b2987 100644 --- a/screenpy_selenium/abilities/browse_the_web.py +++ b/screenpy_selenium/abilities/browse_the_web.py @@ -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" diff --git a/screenpy_selenium/actions/clear.py b/screenpy_selenium/actions/clear.py index 6b84012..2fb4a8f 100644 --- a/screenpy_selenium/actions/clear.py +++ b/screenpy_selenium/actions/clear.py @@ -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 diff --git a/screenpy_selenium/actions/click.py b/screenpy_selenium/actions/click.py index d261904..547997b 100644 --- a/screenpy_selenium/actions/click.py +++ b/screenpy_selenium/actions/click.py @@ -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 diff --git a/screenpy_selenium/actions/double_click.py b/screenpy_selenium/actions/double_click.py index 13c80fb..1a4186c 100644 --- a/screenpy_selenium/actions/double_click.py +++ b/screenpy_selenium/actions/double_click.py @@ -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 diff --git a/screenpy_selenium/actions/enter.py b/screenpy_selenium/actions/enter.py index 5521eca..3895ca4 100644 --- a/screenpy_selenium/actions/enter.py +++ b/screenpy_selenium/actions/enter.py @@ -8,7 +8,6 @@ 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 @@ -16,6 +15,7 @@ if TYPE_CHECKING: from screenpy import Actor from selenium.webdriver.common.action_chains import ActionChains + from typing_extensions import Self from ..target import Target @@ -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 = [] diff --git a/screenpy_selenium/actions/enter_2fa_token.py b/screenpy_selenium/actions/enter_2fa_token.py index e7191a0..32c56f8 100644 --- a/screenpy_selenium/actions/enter_2fa_token.py +++ b/screenpy_selenium/actions/enter_2fa_token.py @@ -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 diff --git a/screenpy_selenium/actions/hold_down.py b/screenpy_selenium/actions/hold_down.py index 4642226..32ffb48 100644 --- a/screenpy_selenium/actions/hold_down.py +++ b/screenpy_selenium/actions/hold_down.py @@ -8,7 +8,6 @@ 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 @@ -16,6 +15,7 @@ if TYPE_CHECKING: from screenpy import Actor from selenium.webdriver.common.action_chains import ActionChains + from typing_extensions import Self from ..target import Target diff --git a/screenpy_selenium/actions/move_mouse.py b/screenpy_selenium/actions/move_mouse.py index 4126760..0bac49a 100644 --- a/screenpy_selenium/actions/move_mouse.py +++ b/screenpy_selenium/actions/move_mouse.py @@ -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 diff --git a/screenpy_selenium/actions/open.py b/screenpy_selenium/actions/open.py index 8f0d017..803ad09 100644 --- a/screenpy_selenium/actions/open.py +++ b/screenpy_selenium/actions/open.py @@ -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: diff --git a/screenpy_selenium/actions/release.py b/screenpy_selenium/actions/release.py index 51743f6..2542c09 100644 --- a/screenpy_selenium/actions/release.py +++ b/screenpy_selenium/actions/release.py @@ -8,7 +8,6 @@ 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 @@ -16,6 +15,7 @@ if TYPE_CHECKING: from screenpy import Actor from selenium.webdriver.common.action_chains import ActionChains + from typing_extensions import Self class Release: diff --git a/screenpy_selenium/actions/respond_to_the_prompt.py b/screenpy_selenium/actions/respond_to_the_prompt.py index bdfac53..94b4d18 100644 --- a/screenpy_selenium/actions/respond_to_the_prompt.py +++ b/screenpy_selenium/actions/respond_to_the_prompt.py @@ -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: diff --git a/screenpy_selenium/actions/right_click.py b/screenpy_selenium/actions/right_click.py index 6da0c9a..73f9f20 100644 --- a/screenpy_selenium/actions/right_click.py +++ b/screenpy_selenium/actions/right_click.py @@ -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 diff --git a/screenpy_selenium/actions/save_console_log.py b/screenpy_selenium/actions/save_console_log.py index cdfb493..d6d5c64 100644 --- a/screenpy_selenium/actions/save_console_log.py +++ b/screenpy_selenium/actions/save_console_log.py @@ -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: diff --git a/screenpy_selenium/actions/save_screenshot.py b/screenpy_selenium/actions/save_screenshot.py index 5812415..7a6821c 100644 --- a/screenpy_selenium/actions/save_screenshot.py +++ b/screenpy_selenium/actions/save_screenshot.py @@ -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: diff --git a/screenpy_selenium/actions/select.py b/screenpy_selenium/actions/select.py index fb58916..8fd9a92 100644 --- a/screenpy_selenium/actions/select.py +++ b/screenpy_selenium/actions/select.py @@ -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 diff --git a/screenpy_selenium/actions/switch_to.py b/screenpy_selenium/actions/switch_to.py index 8862fb7..63e6d32 100644 --- a/screenpy_selenium/actions/switch_to.py +++ b/screenpy_selenium/actions/switch_to.py @@ -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 diff --git a/screenpy_selenium/actions/wait.py b/screenpy_selenium/actions/wait.py index 94fd604..a9c89e7 100644 --- a/screenpy_selenium/actions/wait.py +++ b/screenpy_selenium/actions/wait.py @@ -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 diff --git a/screenpy_selenium/common.py b/screenpy_selenium/common.py index bf85295..c78a26c 100644 --- a/screenpy_selenium/common.py +++ b/screenpy_selenium/common.py @@ -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] diff --git a/screenpy_selenium/questions/list.py b/screenpy_selenium/questions/list.py index a694f08..194e6fc 100644 --- a/screenpy_selenium/questions/list.py +++ b/screenpy_selenium/questions/list.py @@ -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 diff --git a/screenpy_selenium/questions/number.py b/screenpy_selenium/questions/number.py index 201c5bb..2f4b597 100644 --- a/screenpy_selenium/questions/number.py +++ b/screenpy_selenium/questions/number.py @@ -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 diff --git a/screenpy_selenium/questions/selected.py b/screenpy_selenium/questions/selected.py index d6e31de..fac9589 100644 --- a/screenpy_selenium/questions/selected.py +++ b/screenpy_selenium/questions/selected.py @@ -6,12 +6,12 @@ from screenpy.pacing import beat from selenium.webdriver.support.ui import Select as SeleniumSelect -from typing_extensions import Self from ..common import pos_args_deprecated if TYPE_CHECKING: from screenpy import Actor + from typing_extensions import Self from ..target import Target diff --git a/screenpy_selenium/questions/text.py b/screenpy_selenium/questions/text.py index a0cf867..4230dd9 100644 --- a/screenpy_selenium/questions/text.py +++ b/screenpy_selenium/questions/text.py @@ -5,12 +5,12 @@ from typing import TYPE_CHECKING from screenpy.pacing import beat -from typing_extensions import Self from ..common import pos_args_deprecated if TYPE_CHECKING: from screenpy import Actor + from typing_extensions import Self from ..target import Target diff --git a/screenpy_selenium/target.py b/screenpy_selenium/target.py index daa33e1..0f75106 100644 --- a/screenpy_selenium/target.py +++ b/screenpy_selenium/target.py @@ -12,7 +12,6 @@ from selenium.common.exceptions import WebDriverException from selenium.webdriver.common.by import By -from typing_extensions import Self from .abilities.browse_the_web import BrowseTheWeb from .exceptions import TargetingError @@ -20,6 +19,7 @@ if TYPE_CHECKING: from screenpy.actor import Actor from selenium.webdriver.remote.webdriver import WebElement + from typing_extensions import Self class Target: diff --git a/tests/test_actions.py b/tests/test_actions.py index 7e4cf30..e8eb9d6 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -2,18 +2,11 @@ import warnings from contextlib import contextmanager -from typing import Generator, cast +from typing import TYPE_CHECKING, Generator, cast from unittest import mock import pytest -from screenpy import ( - Actor, - DeliveryError, - Describable, - Performable, - UnableToAct, - settings, -) +from screenpy import DeliveryError, Describable, Performable, UnableToAct, settings from screenpy.configuration import ScreenPySettings from screenpy_pyotp.abilities import AuthenticateWith2FA from selenium.common.exceptions import WebDriverException @@ -61,6 +54,9 @@ get_mocked_target_and_element, ) +if TYPE_CHECKING: + from screenpy import Actor + FakeTarget = get_mock_target_class() TARGET = FakeTarget() diff --git a/tests/test_questions.py b/tests/test_questions.py index 23dbd1b..aaff6f7 100644 --- a/tests/test_questions.py +++ b/tests/test_questions.py @@ -1,10 +1,11 @@ from __future__ import annotations import warnings +from typing import TYPE_CHECKING from unittest import mock import pytest -from screenpy import Actor, Answerable, Describable, ErrorKeeper, UnableToAnswer +from screenpy import Answerable, Describable, ErrorKeeper, UnableToAnswer from selenium.common.exceptions import WebDriverException from selenium.webdriver.common.alert import Alert as SeleniumAlert from selenium.webdriver.remote.webelement import WebElement @@ -26,6 +27,9 @@ from .useful_mocks import get_mock_target_class, get_mocked_browser, get_mocked_element +if TYPE_CHECKING: + from screenpy import Actor + FakeTarget = get_mock_target_class() TARGET = FakeTarget()