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

feat: support for URLs #72

Merged
merged 1 commit into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions src/repo_review/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

import importlib.metadata
from collections.abc import Mapping, Set
from typing import Any, ClassVar, Protocol
from typing import Any, Protocol

from .fixtures import apply_fixtures

__all__ = ["Check", "collect_checks", "is_allowed"]


class Check(Protocol):
family: ClassVar[str]
requires: ClassVar[Set[str]] = frozenset()
family: str
requires: Set[str] = frozenset()
url: str = ""

def check(self) -> bool | None | str:
...
Expand Down
3 changes: 3 additions & 0 deletions src/repo_review/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ResultDict(typing.TypedDict):
description: str
result: bool | None
err_msg: str
url: str


@dataclasses.dataclass(frozen=True, kw_only=True)
Expand All @@ -38,6 +39,7 @@ class Result:
description: str
result: bool | None
err_msg: str = ""
url: str = ""

def err_markdown(self) -> str:
result: str = md.render(self.err_msg).strip()
Expand Down Expand Up @@ -120,6 +122,7 @@ def process(package: Traversable, *, ignore: Sequence[str] = ()) -> ProcessRetur
description=doc,
result=result,
err_msg=textwrap.dedent(err_msg.format(cls=check)),
url=getattr(check, "url", ""),
)
)

Expand Down
3 changes: 3 additions & 0 deletions tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class D100:
"Was passed correctly"
family = "pyproject"
url = "https://example.com"

@staticmethod
def check(package: Traversable) -> bool:
Expand Down Expand Up @@ -84,8 +85,10 @@ def test_custom_checks(monkeypatch: pytest.MonkeyPatch) -> None:
assert len(results) == 2
assert results[0].name == "D100"
assert results[0].result
assert results[0].url == "https://example.com"
assert results[1].name == "D200"
assert results[1].result
assert not results[1].url
assert len(results) == 2


Expand Down