Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard type hinting via ruff #166

Merged
merged 5 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ name = 'Trivial Changes'
showcontent = false

[tool.ruff]
src = ["src"]
line-length = 88

[tool.ruff.lint]
select = ["C","E","F","W","B","RUF","PLE","PLW"]
select = ["C","E","F","W","B","RUF","PLE","PLW","I","TCH","FA"]
ignore = ["PLW2901"]
exclude = [
".git",
Expand All @@ -96,9 +97,6 @@ exclude = [
"*.pyi"
]

[tool.ruff.lint.isort]
known-first-party = ["resolvelib"]

[tool.mypy]
warn_unused_configs = true

Expand Down
6 changes: 3 additions & 3 deletions src/resolvelib/resolvers/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import collections
from typing import TYPE_CHECKING, Any, Generic, Iterable, Mapping, NamedTuple

from ..providers import AbstractProvider
from ..reporters import BaseReporter
from ..structs import CT, KT, RT, DirectedGraph
from .criterion import Criterion

if TYPE_CHECKING:
from ..providers import AbstractProvider
from ..reporters import BaseReporter
from .criterion import Criterion

class Result(NamedTuple, Generic[RT, CT, KT]):
mapping: Mapping[KT, CT]
Expand Down
6 changes: 4 additions & 2 deletions src/resolvelib/resolvers/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import annotations

from typing import Collection, Generic
from typing import TYPE_CHECKING, Collection, Generic

from ..structs import CT, RT, RequirementInformation
from .criterion import Criterion

if TYPE_CHECKING:
from .criterion import Criterion


class ResolverException(Exception):
Expand Down
5 changes: 2 additions & 3 deletions src/resolvelib/resolvers/resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import operator
from typing import TYPE_CHECKING, Collection, Generic, Iterable, Mapping

from ..providers import AbstractProvider
from ..reporters import BaseReporter
from ..structs import (
CT,
KT,
Expand All @@ -29,7 +27,8 @@
)

if TYPE_CHECKING:
from ..providers import Preference
from ..providers import AbstractProvider, Preference
from ..reporters import BaseReporter


def _build_result(state: State[RT, CT, KT]) -> Result[RT, CT, KT]:
Expand Down
7 changes: 5 additions & 2 deletions tests/test_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@
InconsistentCandidate,
ResolutionImpossible,
)
from resolvelib.resolvers import Resolution, Resolver
from resolvelib.resolvers import (
RequirementsConflicted,
Resolution,
Resolver,
)

if TYPE_CHECKING:
from typing import Iterable, Mapping

from resolvelib.resolvers import (
Criterion,
RequirementInformation,
RequirementsConflicted,
)


Expand Down
Loading