Skip to content

Commit 8ba0212

Browse files
authored
fix: error if both target-version and project.requires-python are set (#383)
fix: error if both target-version and project.requires-python are set, too Signed-off-by: Henry Schreiner <[email protected]>
1 parent 34b3f41 commit 8ba0212

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

docs/pages/guides/repo_review.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fail, that's okay - the goal is bring all possible issues to your attention, not
1818
to force compliance with arbitrary checks.
1919

2020
You can also run [this tool](https://github.com/scientific-python/repo-review)
21-
locally:
21+
locally (Python 3.10+ required):
2222

2323
```bash
2424
pipx run 'sp-repo-review[cli]' <path to repo>

src/sp_repo_review/checks/mypy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class MY102(MyPy):
6464
@staticmethod
6565
def check(pyproject: dict[str, Any]) -> bool:
6666
"""
67-
Must not have `show_error_codes`. Use `hide_error_codes` instead (since MyPy v0.990).
67+
Must not have `show_error_codes`. It is now the default, or you can
68+
use `hide_error_codes` with the reverse value instead (since MyPy v0.990).
6869
"""
6970

7071
match pyproject:

src/sp_repo_review/checks/ruff.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,19 @@ class RF002(Ruff):
6666
"Target version must be set"
6767

6868
@staticmethod
69-
def check(pyproject: dict[str, Any], ruff: dict[str, Any]) -> bool:
69+
def check(pyproject: dict[str, Any], ruff: dict[str, Any]) -> bool | str:
7070
"""
7171
Must select a minimum version to target. Affects pyupgrade, isort, and
7272
others. Will be inferred from `project.requires-python`.
7373
"""
7474

75-
if "target-version" in ruff:
76-
return True
77-
7875
match pyproject:
7976
case {"project": {"requires-python": str()}}:
77+
if "target-version" in ruff:
78+
return "You have both Ruff's `target-version` and `project.requires-python`. You only need the later."
8079
return True
8180
case _:
82-
return False
81+
return "target-version" in ruff
8382

8483

8584
class RF003(Ruff):

0 commit comments

Comments
 (0)