Skip to content

Commit eda52cb

Browse files
committed
Fix PC191 raising TypeError when no ruff config present
1 parent 24700e7 commit eda52cb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/sp_repo_review/checks/precommit.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ class PC191(PreCommit):
149149
repos = {"https://github.com/astral-sh/ruff-pre-commit"}
150150

151151
@classmethod
152-
def check(cls, precommit: dict[str, Any], ruff: dict[str, Any]) -> bool | None: # type: ignore[override]
152+
def check( # type: ignore[override]
153+
cls,
154+
precommit: dict[str, Any],
155+
ruff: dict[str, Any] | None,
156+
) -> bool | None:
153157
"""
154158
If `--fix` is present, `--show-fixes` must be too.
155159
"""
@@ -161,7 +165,9 @@ def check(cls, precommit: dict[str, Any], ruff: dict[str, Any]) -> bool | None:
161165
and "args" in hook
162166
and "--fix" in hook["args"]
163167
):
164-
return "--show-fixes" in hook["args"] or "show-fixes" in ruff
168+
return "--show-fixes" in hook["args"] or (
169+
ruff is not None and "show-fixes" in ruff
170+
)
165171
return None
166172
return False
167173

0 commit comments

Comments
 (0)