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 537f932 commit 8953ddc
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 21 deletions.
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ ignore = [
"ANN102", # missing cls annotation, we only annotate cls when we return it.
]

extend-safe-fixes = [
"EM101",
"EM102",
"TCH001", "TCH002", "TCH003", "TCH004",
"C419",
"D200", "D205", "D415",
"PT003", "PT006", "PT018",
"RET504",
"UP006", "UP007",
]

[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"D", # we don't need public-API-polished docstrings in tests.
Expand Down Expand Up @@ -206,6 +217,10 @@ ignore-overlong-task-comments = true
convention = "google"


[tool.ruff.lint.flake8-type-checking]
strict = true


[build-system]
requires = ["poetry-core>=1.2.0"]
build-backend = "poetry.core.masonry.api"
4 changes: 2 additions & 2 deletions screenpy/actions/either.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

from typing import TYPE_CHECKING

from typing_extensions import Self

from screenpy.configuration import settings
from screenpy.pacing import the_narrator
from screenpy.speech_tools import get_additive_description

if TYPE_CHECKING:
from typing_extensions import Self

from screenpy import Actor
from screenpy.protocols import Performable

Expand Down
4 changes: 2 additions & 2 deletions screenpy/actions/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

from typing import TYPE_CHECKING

from typing_extensions import Self

from screenpy.pacing import aside, beat
from screenpy.protocols import Answerable
from screenpy.speech_tools import get_additive_description, represent_prop

if TYPE_CHECKING:
from typing_extensions import Self

from screenpy.actor import Actor

from .see import T_Q
Expand Down
4 changes: 2 additions & 2 deletions screenpy/actions/make_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

from typing import TYPE_CHECKING

from typing_extensions import Self

from screenpy.director import Director
from screenpy.exceptions import UnableToAct
from screenpy.pacing import aside, beat
Expand All @@ -15,6 +13,8 @@
if TYPE_CHECKING:
from typing import Union

from typing_extensions import Self

from screenpy.actor import Actor

T_Q = Union[Answerable, object]
Expand Down
4 changes: 2 additions & 2 deletions screenpy/actions/pause.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from time import sleep
from typing import TYPE_CHECKING

from typing_extensions import Self

from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat

if TYPE_CHECKING:

from typing_extensions import Self

from screenpy.actor import Actor


Expand Down
6 changes: 4 additions & 2 deletions screenpy/actions/see.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
from typing import TYPE_CHECKING

from hamcrest import assert_that
from typing_extensions import Self

from screenpy.pacing import aside, beat
from screenpy.protocols import Answerable, ErrorKeeper, Resolvable
from screenpy.protocols import Answerable, ErrorKeeper
from screenpy.speech_tools import get_additive_description, represent_prop

if TYPE_CHECKING:
from typing import Union

from typing_extensions import Self

from screenpy.actor import Actor
from screenpy.protocols import Resolvable

T_Q = Union[Answerable, object]
T_R = Resolvable
Expand Down
4 changes: 2 additions & 2 deletions screenpy/actions/see_all_of.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

from typing import TYPE_CHECKING, Tuple

from typing_extensions import Self

from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat

from .see import See

if TYPE_CHECKING:
from typing_extensions import Self

from screenpy.actor import Actor

from .see import T_Q, T_R
Expand Down
4 changes: 2 additions & 2 deletions screenpy/actions/see_any_of.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

from typing import TYPE_CHECKING

from typing_extensions import Self

from screenpy.exceptions import UnableToAct
from screenpy.pacing import beat

Expand All @@ -14,6 +12,8 @@
if TYPE_CHECKING:
from typing import Tuple

from typing_extensions import Self

from screenpy.actor import Actor

from .see import T_Q, T_R
Expand Down
11 changes: 7 additions & 4 deletions screenpy/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
from __future__ import annotations

from random import choice
from typing import TypeVar

from typing_extensions import Self
from typing import TYPE_CHECKING, TypeVar

from .exceptions import UnableToPerform
from .pacing import aside
from .protocols import Forgettable, Performable
from .protocols import Forgettable
from .speech_tools import get_additive_description

if TYPE_CHECKING:
from typing_extensions import Self

from .protocols import Performable

# pylint: disable=too-many-public-methods

ENTRANCE_DIRECTIONS = [
Expand Down
5 changes: 3 additions & 2 deletions screenpy/director.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

from __future__ import annotations

from typing import Any
from typing import TYPE_CHECKING, Any

from typing_extensions import Self
if TYPE_CHECKING:
from typing_extensions import Self


class Director:
Expand Down
4 changes: 3 additions & 1 deletion tests/test_pacing_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import logging
from typing import TYPE_CHECKING

from screenpy import Actor, IsEqualTo, See, beat
from screenpy import IsEqualTo, See, beat

if TYPE_CHECKING:
import pytest

from screenpy import Actor


class CornerCase:
@beat("{} examines CornerCase")
Expand Down

0 comments on commit 8953ddc

Please sign in to comment.