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 a62e225 commit 282a5cb
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 22 deletions.
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ black-check:
black-fix:
black .

isort-check:
isort . --check

isort-fix:
isort .

ruff-check:
ruff check .

Expand All @@ -44,10 +38,11 @@ ruff-fix:
mypy:
mypy .

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

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

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

.PHONY: pre-check-in pre-check-in-fix

9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,11 @@ extend-safe-fixes = [
"EM101",
"EM102",
"TCH001", "TCH002", "TCH003", "TCH004",
# "SIM108"
# maybe?
# "F841",
"C419",
"D200", "D205", "D415",
"PT003", "PT006", "PT018",
"RET504",
"UP006",
"UP007",
"UP006", "UP007",
]

[tool.ruff.lint.per-file-ignores]
Expand All @@ -203,3 +199,6 @@ ignore-overlong-task-comments = true

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.lint.flake8-type-checking]
strict = true
7 changes: 5 additions & 2 deletions screenpy_requests/abilities/make_api_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

from __future__ import annotations

from typing import Any, Callable
from typing import TYPE_CHECKING, Any, Callable

from requests import Response, Session
from requests import Session

from ..exceptions import RequestError

if TYPE_CHECKING:
from requests import Response


class MakeAPIRequests:
"""Use Requests to enable sending API requests.
Expand Down
7 changes: 5 additions & 2 deletions screenpy_requests/actions/add_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

from __future__ import annotations

from typing import Iterable, cast
from typing import TYPE_CHECKING, Iterable, cast

from screenpy import Actor, aside, beat
from screenpy import aside, beat
from screenpy.narration import AIRY

from ..abilities import MakeAPIRequests

if TYPE_CHECKING:
from screenpy import Actor


class AddHeader:
"""Add one or more headers to the Actor's API session.
Expand Down
7 changes: 5 additions & 2 deletions screenpy_requests/actions/send_api_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

from __future__ import annotations

from typing import Any
from typing import TYPE_CHECKING, Any

from screenpy import Actor, aside, beat
from screenpy import aside, beat
from screenpy.narration import AIRY

from ..abilities import MakeAPIRequests

if TYPE_CHECKING:
from screenpy import Actor


class SendAPIRequest:
"""Send an API request.
Expand Down
7 changes: 5 additions & 2 deletions screenpy_requests/actions/set_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

from __future__ import annotations

from typing import Iterable, cast
from typing import TYPE_CHECKING, Iterable, cast

from screenpy import Actor, aside, beat
from screenpy import aside, beat
from screenpy.narration import AIRY

from ..abilities import MakeAPIRequests

if TYPE_CHECKING:
from screenpy import Actor


class SetHeaders:
"""Set the headers of the Actor's API session to this specific set.
Expand Down
5 changes: 3 additions & 2 deletions tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from screenpy_requests.actions import (
AddHeader,
AddHeaders,
APIMethodAction,
SendAPIRequest,
SendDELETERequest,
SendGETRequest,
Expand All @@ -26,6 +25,8 @@
if TYPE_CHECKING:
from screenpy import Actor

from screenpy_requests.actions import APIMethodAction


class TestAddHeader:
def test_can_be_instantiated(self) -> None:
Expand Down Expand Up @@ -98,7 +99,7 @@ def test_hides_secret_headers(

def test_generate_send_method_class_docstring() -> None:
"""Generated class and method's docstring both contain method name."""
test_method: str = "TESTYTEST"
test_method = "TESTYTEST"

SendTESTMethod = generate_send_method_class(test_method)

Expand Down

0 comments on commit 282a5cb

Please sign in to comment.