Skip to content

Commit

Permalink
Enable TCH rules for slightly reducing runtime imports.
Browse files Browse the repository at this point in the history
Catches typing imports that are only needed for type checking.
  • Loading branch information
Julian committed Nov 9, 2023
1 parent cc7e525 commit 925f7ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ exclude = [

[tool.ruff]
line-length = 79
select = ["ANN", "B", "D", "D204", "E", "F", "Q", "RUF", "SIM", "UP", "W"]
select = [
"ANN", "B", "D", "D204", "E", "F", "Q", "RUF", "SIM", "TCH", "UP", "W",
]
ignore = [
# Wat, type annotations for self and cls, why is this a thing?
"ANN101",
Expand Down
2 changes: 1 addition & 1 deletion referencing/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import attrs

from referencing._attrs import frozen
from referencing.typing import URI

if TYPE_CHECKING:
from referencing import Resource
from referencing.typing import URI


@frozen
Expand Down
6 changes: 4 additions & 2 deletions referencing/retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
from __future__ import annotations

from functools import lru_cache
from typing import Callable, TypeVar
from typing import TYPE_CHECKING, Callable, TypeVar
import json

from referencing import Resource
from referencing.typing import URI, D, Retrieve

if TYPE_CHECKING:
from referencing.typing import URI, D, Retrieve

#: A serialized document (e.g. a JSON string)
_T = TypeVar("_T")
Expand Down

0 comments on commit 925f7ec

Please sign in to comment.