Skip to content

Commit

Permalink
chore: move to ruff-format (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii authored Oct 28, 2023
1 parent d5add10 commit d5784ef
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
10 changes: 3 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@ ci:
autofix_commit_msg: "style: pre-commit fixes"

repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.0
hooks:
- id: black-jupyter

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.7.0]
additional_dependencies: [black==23.*]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.1"
rev: "v0.1.3"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.3"
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def nocolor(monkeypatch: pytest.MonkeyPatch) -> None:
@pytest.fixture()
def no_entry_points(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(
importlib.metadata, "entry_points", lambda group: [] # noqa: ARG005
importlib.metadata,
"entry_points",
lambda group: [], # noqa: ARG005
)


Expand Down
11 changes: 9 additions & 2 deletions tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

class D100:
"Was passed correctly"

family = "pyproject"
url = "https://example.com"

Expand All @@ -28,6 +29,7 @@ def check(package: Traversable) -> bool:

class D200:
"Always true"

family = "pyproject"

@staticmethod
Expand All @@ -42,6 +44,7 @@ def check() -> bool:
@dataclasses.dataclass(frozen=True, kw_only=True)
class C100:
"Can compute custom output strings"

fail: bool
family: ClassVar[str] = "custom"

Expand All @@ -52,7 +55,9 @@ def check(self, name: str) -> str:

def test_no_checks(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(
importlib.metadata, "entry_points", lambda group: [] # noqa: ARG005
importlib.metadata,
"entry_points",
lambda group: [], # noqa: ARG005
)

_, results = repo_review.processor.process(Path())
Expand All @@ -64,7 +69,9 @@ def test_load_entry_point(monkeypatch: pytest.MonkeyPatch) -> None:
sys.modules["test_module"] = ModuleType("test_module")
sys.modules["test_module"].f = lambda: {"D100": D100, "D200": D200} # type: ignore[attr-defined]
monkeypatch.setattr(
importlib.metadata, "entry_points", lambda group: [ep] # noqa: ARG005
importlib.metadata,
"entry_points",
lambda group: [ep], # noqa: ARG005
)
checks = collect_checks({"package": Path()})

Expand Down
6 changes: 5 additions & 1 deletion tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

class D100:
"Was passed correctly"

family = "pyproject"

@staticmethod
Expand All @@ -25,6 +26,7 @@ def check(package: Traversable) -> bool:

class D200:
"Always true"

family = "pyproject"

@staticmethod
Expand Down Expand Up @@ -87,7 +89,9 @@ def test_process_checks(monkeypatch: pytest.MonkeyPatch, some_bool: bool) -> Non
sys.modules["test_module"] = ModuleType("test_module")
sys.modules["test_module"].f = get_checks # type: ignore[attr-defined]
monkeypatch.setattr(
importlib.metadata, "entry_points", lambda group: [ep] # noqa: ARG005
importlib.metadata,
"entry_points",
lambda group: [ep], # noqa: ARG005
)
checks = collect_checks({"package": Path(), "some_bool": some_bool})
assert len(checks) == 1 + some_bool
1 change: 1 addition & 0 deletions tests/test_utilities/pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def check(pyproject: dict[str, Any]) -> bool:

class PP302(PyProject):
"Sets a minimum pytest to at least 6"

requires = frozenset(("PP301",))

@staticmethod
Expand Down

0 comments on commit d5784ef

Please sign in to comment.