repo-review 0.10.3__py3-none-any.whl → 0.10.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- repo_review/__init__.py +0 -1
- repo_review/__main__.py +9 -3
- repo_review/_compat/importlib/resources/abc.py +1 -0
- repo_review/_version.py +2 -2
- repo_review/checks.py +23 -0
- repo_review/fixtures.py +2 -1
- repo_review/ghpath.py +4 -8
- repo_review/processor.py +9 -13
- repo_review/testing.py +51 -0
- {repo_review-0.10.3.dist-info → repo_review-0.10.5.dist-info}/METADATA +16 -5
- {repo_review-0.10.3.dist-info → repo_review-0.10.5.dist-info}/RECORD +14 -13
- {repo_review-0.10.3.dist-info → repo_review-0.10.5.dist-info}/WHEEL +1 -1
- {repo_review-0.10.3.dist-info → repo_review-0.10.5.dist-info}/entry_points.txt +0 -0
- {repo_review-0.10.3.dist-info → repo_review-0.10.5.dist-info}/licenses/LICENSE +0 -0
repo_review/__init__.py
CHANGED
repo_review/__main__.py
CHANGED
@@ -34,12 +34,16 @@ from .processor import Result, as_simple_dict, collect_all, process
|
|
34
34
|
|
35
35
|
__all__ = ["main", "Formats", "Show", "Status"]
|
36
36
|
|
37
|
+
CODE_THEME = "default"
|
38
|
+
|
37
39
|
|
38
40
|
def __dir__() -> list[str]:
|
39
41
|
return __all__
|
40
42
|
|
41
43
|
|
42
|
-
rich.traceback.install(
|
44
|
+
rich.traceback.install(
|
45
|
+
suppress=[click, rich, orig_click], show_locals=False, width=None
|
46
|
+
)
|
43
47
|
|
44
48
|
Status = Literal["empty", "passed", "skips", "errors"]
|
45
49
|
Formats = Literal["rich", "json", "html", "svg"]
|
@@ -94,7 +98,9 @@ def rich_printer(
|
|
94
98
|
# Compute the family name and optional description
|
95
99
|
rich_family_name = rich.text.Text.from_markup(f"[bold]{family_name}[/bold]:")
|
96
100
|
if family_description:
|
97
|
-
rich_description = rich.markdown.Markdown(
|
101
|
+
rich_description = rich.markdown.Markdown(
|
102
|
+
family_description, code_theme=CODE_THEME
|
103
|
+
)
|
98
104
|
rich_family = rich.console.Group(
|
99
105
|
rich_family_name, rich_description, rich.console.NewLine()
|
100
106
|
)
|
@@ -127,7 +133,7 @@ def rich_printer(
|
|
127
133
|
tree.add(msg)
|
128
134
|
else:
|
129
135
|
msg.append(rich.text.Text.from_markup(" :x:"))
|
130
|
-
detail = rich.markdown.Markdown(result.err_msg)
|
136
|
+
detail = rich.markdown.Markdown(result.err_msg, code_theme=CODE_THEME)
|
131
137
|
msg_grp = rich.console.Group(msg, detail)
|
132
138
|
tree.add(msg_grp)
|
133
139
|
|
repo_review/_version.py
CHANGED
repo_review/checks.py
CHANGED
@@ -120,3 +120,26 @@ def get_check_description(name: str, check: Check) -> str:
|
|
120
120
|
.. versionadded:: 0.8
|
121
121
|
"""
|
122
122
|
return (check.__doc__ or "").format(self=check, name=name)
|
123
|
+
|
124
|
+
|
125
|
+
def process_result_bool(
|
126
|
+
result: str | bool | None, check: Check, name: str
|
127
|
+
) -> str | None:
|
128
|
+
"""
|
129
|
+
This converts a bool into a string given a check and name. If the result is a string
|
130
|
+
or None, it is returned as is.
|
131
|
+
|
132
|
+
:param result: The result to process.
|
133
|
+
:param check: The check instance.
|
134
|
+
:param name: The name of the check.
|
135
|
+
:return: The final string or None.
|
136
|
+
|
137
|
+
.. versionadded:: 0.11
|
138
|
+
"""
|
139
|
+
if isinstance(result, bool):
|
140
|
+
return (
|
141
|
+
""
|
142
|
+
if result
|
143
|
+
else (check.check.__doc__ or "Check failed").format(name=name, self=check)
|
144
|
+
)
|
145
|
+
return result
|
repo_review/fixtures.py
CHANGED
@@ -36,7 +36,8 @@ def pyproject(package: Traversable) -> dict[str, Any]:
|
|
36
36
|
pyproject_path = package.joinpath("pyproject.toml")
|
37
37
|
if pyproject_path.is_file():
|
38
38
|
with pyproject_path.open("rb") as f:
|
39
|
-
|
39
|
+
# Type ignore fixed in https://github.com/hukkin/tomli/pull/215
|
40
|
+
return tomllib.load(f) # type: ignore[arg-type]
|
40
41
|
return {}
|
41
42
|
|
42
43
|
|
repo_review/ghpath.py
CHANGED
@@ -76,12 +76,10 @@ class GHPath(Traversable):
|
|
76
76
|
return (self.path or self.repo).split("/")[-1]
|
77
77
|
|
78
78
|
@typing.overload # type: ignore[override]
|
79
|
-
def open(self, mode: Literal["r"], encoding: str | None = ...) -> io.StringIO:
|
80
|
-
...
|
79
|
+
def open(self, mode: Literal["r"], encoding: str | None = ...) -> io.StringIO: ...
|
81
80
|
|
82
81
|
@typing.overload
|
83
|
-
def open(self, mode: Literal["rb"]) -> io.BytesIO:
|
84
|
-
...
|
82
|
+
def open(self, mode: Literal["rb"]) -> io.BytesIO: ...
|
85
83
|
|
86
84
|
def open(
|
87
85
|
self, mode: Literal["r", "rb"] = "r", encoding: str | None = "utf-8"
|
@@ -164,12 +162,10 @@ class EmptyTraversable(Traversable):
|
|
164
162
|
return self._fake_name
|
165
163
|
|
166
164
|
@typing.overload # type: ignore[override]
|
167
|
-
def open(self, mode: Literal["r"], encoding: str | None = ...) -> io.StringIO:
|
168
|
-
...
|
165
|
+
def open(self, mode: Literal["r"], encoding: str | None = ...) -> io.StringIO: ...
|
169
166
|
|
170
167
|
@typing.overload
|
171
|
-
def open(self, mode: Literal["rb"]) -> io.BytesIO:
|
172
|
-
...
|
168
|
+
def open(self, mode: Literal["rb"]) -> io.BytesIO: ...
|
173
169
|
|
174
170
|
def open(
|
175
171
|
self, mode: Literal["r", "rb"] = "r", encoding: str | None = "utf-8"
|
repo_review/processor.py
CHANGED
@@ -10,7 +10,13 @@ from typing import Any, TypeVar
|
|
10
10
|
import markdown_it
|
11
11
|
|
12
12
|
from ._compat.importlib.resources.abc import Traversable
|
13
|
-
from .checks import
|
13
|
+
from .checks import (
|
14
|
+
Check,
|
15
|
+
collect_checks,
|
16
|
+
get_check_url,
|
17
|
+
is_allowed,
|
18
|
+
process_result_bool,
|
19
|
+
)
|
14
20
|
from .families import Family, collect_families
|
15
21
|
from .fixtures import apply_fixtures, collect_fixtures, compute_fixtures, pyproject
|
16
22
|
from .ghpath import EmptyTraversable
|
@@ -108,8 +114,7 @@ class HasFamily(typing.Protocol):
|
|
108
114
|
"""
|
109
115
|
|
110
116
|
@property
|
111
|
-
def family(self) -> str:
|
112
|
-
...
|
117
|
+
def family(self) -> str: ...
|
113
118
|
|
114
119
|
|
115
120
|
T = TypeVar("T", bound=HasFamily)
|
@@ -212,16 +217,7 @@ def process(
|
|
212
217
|
for name in ts.static_order():
|
213
218
|
if all(completed.get(n, "") == "" for n in graph[name]):
|
214
219
|
result = apply_fixtures({"name": name, **fixtures}, tasks[name].check)
|
215
|
-
|
216
|
-
completed[name] = (
|
217
|
-
""
|
218
|
-
if result
|
219
|
-
else (tasks[name].check.__doc__ or "Check failed").format(
|
220
|
-
name=name, self=tasks[name]
|
221
|
-
)
|
222
|
-
)
|
223
|
-
else:
|
224
|
-
completed[name] = result
|
220
|
+
completed[name] = process_result_bool(result, tasks[name], name)
|
225
221
|
else:
|
226
222
|
completed[name] = None
|
227
223
|
|
repo_review/testing.py
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
"""
|
2
|
+
Helpers for testing repo-review plugins.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from __future__ import annotations
|
6
|
+
|
7
|
+
import importlib.metadata
|
8
|
+
import textwrap
|
9
|
+
from typing import Any
|
10
|
+
|
11
|
+
from .checks import Check, get_check_url, process_result_bool
|
12
|
+
from .fixtures import apply_fixtures
|
13
|
+
from .processor import Result
|
14
|
+
|
15
|
+
|
16
|
+
def compute_check(name: str, /, **fixtures: Any) -> Result:
|
17
|
+
"""
|
18
|
+
A helper function to compute a check given fixtures, intended for testing.
|
19
|
+
Currently, all fixtures are required to be passed in as keyword arguments,
|
20
|
+
transitive fixtures are not supported.
|
21
|
+
|
22
|
+
:param name: The name of the check to compute.
|
23
|
+
:param fixtures: The fixtures to use when computing the check.
|
24
|
+
:return: The computed result.
|
25
|
+
|
26
|
+
.. versionadded:: 0.10.5
|
27
|
+
"""
|
28
|
+
|
29
|
+
check_functions = (
|
30
|
+
ep.load() for ep in importlib.metadata.entry_points(group="repo_review.checks")
|
31
|
+
)
|
32
|
+
checks = {
|
33
|
+
k: v
|
34
|
+
for func in check_functions
|
35
|
+
for k, v in apply_fixtures(fixtures, func).items()
|
36
|
+
}
|
37
|
+
check: Check = checks[name]
|
38
|
+
completed_raw = apply_fixtures({"name": name, **fixtures}, check.check)
|
39
|
+
completed = process_result_bool(completed_raw, check, name)
|
40
|
+
result = None if completed is None else not completed
|
41
|
+
doc = check.__doc__ or ""
|
42
|
+
err_msg = completed or ""
|
43
|
+
|
44
|
+
return Result(
|
45
|
+
family=check.family,
|
46
|
+
name=name,
|
47
|
+
description=doc.format(self=check, name=name).strip(),
|
48
|
+
result=result,
|
49
|
+
err_msg=textwrap.dedent(err_msg),
|
50
|
+
url=get_check_url(name, check),
|
51
|
+
)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.3
|
2
2
|
Name: repo_review
|
3
|
-
Version: 0.10.
|
3
|
+
Version: 0.10.5
|
4
4
|
Summary: Framework that can run checks on repos
|
5
5
|
Project-URL: Changelog, https://github.com/scientific-python/repo-review/releases
|
6
6
|
Project-URL: Demo, https://scientific-python.github.io/repo-review
|
@@ -34,11 +34,18 @@ Requires-Dist: click>=8; extra == 'cli'
|
|
34
34
|
Requires-Dist: rich-click; extra == 'cli'
|
35
35
|
Requires-Dist: rich>=12.2; extra == 'cli'
|
36
36
|
Provides-Extra: dev
|
37
|
-
Requires-Dist:
|
37
|
+
Requires-Dist: click>=8; extra == 'dev'
|
38
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
39
|
+
Requires-Dist: rich-click; extra == 'dev'
|
40
|
+
Requires-Dist: rich>=12.2; extra == 'dev'
|
41
|
+
Requires-Dist: sp-repo-review>=2023.12.21; extra == 'dev'
|
42
|
+
Requires-Dist: validate-pyproject>=0.14; extra == 'dev'
|
38
43
|
Provides-Extra: docs
|
44
|
+
Requires-Dist: click>=8; extra == 'docs'
|
39
45
|
Requires-Dist: furo; extra == 'docs'
|
40
46
|
Requires-Dist: myst-parser>=0.13; extra == 'docs'
|
41
|
-
Requires-Dist:
|
47
|
+
Requires-Dist: rich-click; extra == 'docs'
|
48
|
+
Requires-Dist: rich>=12.2; extra == 'docs'
|
42
49
|
Requires-Dist: sphinx-autodoc-typehints; extra == 'docs'
|
43
50
|
Requires-Dist: sphinx-copybutton; extra == 'docs'
|
44
51
|
Requires-Dist: sphinx-github-changelog; extra == 'docs'
|
@@ -57,6 +64,7 @@ Description-Content-Type: text/markdown
|
|
57
64
|
[![Documentation Status][docs-badge]][docs-link]
|
58
65
|
|
59
66
|
[![PyPI version][pypi-version]][pypi-link]
|
67
|
+
[![Conda-Forge][conda-badge]][conda-link]
|
60
68
|
[![PyPI platforms][pypi-platforms]][pypi-link]
|
61
69
|
|
62
70
|
<!-- SPHINX-START -->
|
@@ -76,7 +84,7 @@ These are some known plugins. Feel free to request your plugin be added to this
|
|
76
84
|
list.
|
77
85
|
|
78
86
|
- [sp-repo-review][]: Checks based on the [Scientific-Python Development Guide][] at [scientific-python/cookie][].
|
79
|
-
- [validate-pyproject][]: Adds a check to validate pyproject sections, also supports plugins.
|
87
|
+
- [validate-pyproject][]: Adds a check to validate pyproject sections, also supports plugins (like [validate-pyproject-schema-store][]).
|
80
88
|
|
81
89
|
`repo-review` itself also acts as a plugin for [validate-pyproject][], allowing
|
82
90
|
you to validate the `[tool.repo-review]` section of your `pyproject.toml`.
|
@@ -211,6 +219,9 @@ This was developed for [Scikit-HEP][] before moving to Scientific-Python.
|
|
211
219
|
[scikit-hep]: https://scikit-hep.org
|
212
220
|
[sp-repo-review]: https://pypi.org/project/sp-repo-review
|
213
221
|
[validate-pyproject]: https://validate-pyproject.readthedocs.io
|
222
|
+
[validate-pyproject-schema-store]: https://github.com/henryiii/validate-pyproject-schema-store
|
223
|
+
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/repo-review
|
224
|
+
[conda-link]: https://github.com/conda-forge/repo-review-feedstock
|
214
225
|
|
215
226
|
[intro-pre-commit]: https://repo-review.readthedocs.io/en/latest/intro.html#pre-commit
|
216
227
|
[intro-github-actions]: https://repo-review.readthedocs.io/en/latest/intro.html#github-actions
|
@@ -1,25 +1,26 @@
|
|
1
|
-
repo_review/__init__.py,sha256=
|
2
|
-
repo_review/__main__.py,sha256=
|
3
|
-
repo_review/_version.py,sha256=
|
1
|
+
repo_review/__init__.py,sha256=U03wTpj7PjSsIROp8O4VRG_NVG-plkx14d_MvqpmJ_w,229
|
2
|
+
repo_review/__main__.py,sha256=YG78gWDM5ExHNTEhdtMNGvJBV44JU_IkR5mc_3a5fqs,12262
|
3
|
+
repo_review/_version.py,sha256=JrZYbNAlpJOYXO5cv0MZXjpyEhQ6EOMM22X9FTSLwks,413
|
4
4
|
repo_review/_version.pyi,sha256=j5kbzfm6lOn8BzASXWjGIA1yT0OlHTWqlbyZ8Si_o0E,118
|
5
|
-
repo_review/checks.py,sha256=
|
5
|
+
repo_review/checks.py,sha256=hIwQARm0JESf0yMCfjR5jaI-AdnCO7ePTY28eQ2iOy4,4340
|
6
6
|
repo_review/families.py,sha256=TEMQY3whMj8b3iVlWyVsTa0CAZexXRCFXq5uPIkV6bs,2389
|
7
|
-
repo_review/fixtures.py,sha256=
|
8
|
-
repo_review/ghpath.py,sha256=
|
7
|
+
repo_review/fixtures.py,sha256=AHdUhDU--SOrlhWSymiyECp5LmaCGYNRcZHuPpzFUts,3709
|
8
|
+
repo_review/ghpath.py,sha256=s83SiaSyfINvtuLn3wpNPQeiU3FipulgTQJObQ9m7tg,5978
|
9
9
|
repo_review/html.py,sha256=LwoZUqiWC84qSuhwbzqQtwhWDhE8JiPWWTI4nKXF3nA,3485
|
10
|
-
repo_review/processor.py,sha256=
|
10
|
+
repo_review/processor.py,sha256=2NSbuC7jt_eMjIB9VpY0c5-TtKr9GWzA8Gr6Pvj2SqU,7951
|
11
11
|
repo_review/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
repo_review/schema.py,sha256=U_iox0khN1oEHCCB5ILffjRvZLG7BR-aaip9QEpMkJk,593
|
13
|
+
repo_review/testing.py,sha256=zusrj_v9G7WAAGcv1S0Tzijanf02HuZUYKE00wpwIj4,1523
|
13
14
|
repo_review/_compat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
15
|
repo_review/_compat/tomllib.py,sha256=caR8Mj-hSBLE2zqdLLjzwOdCBOfikVqS8pWkc4K5vgc,233
|
15
16
|
repo_review/_compat/typing.py,sha256=vXfYiJHUaqMShRMbJi0VUg2V59UV-oxceZKSBZ3tfts,246
|
16
17
|
repo_review/_compat/importlib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
18
|
repo_review/_compat/importlib/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
|
-
repo_review/_compat/importlib/resources/abc.py,sha256=
|
19
|
+
repo_review/_compat/importlib/resources/abc.py,sha256=KLv7AqUaY-ezZ32lA5yVcZLfMqY6VEo8Q-1jyWpGRbk,300
|
19
20
|
repo_review/resources/__init__.py,sha256=RBBaUp-hQrIYBqbAT0MytCXEjDmqVsCjiEgdK_K3dN4,138
|
20
21
|
repo_review/resources/repo-review.schema.json,sha256=Ljna-BRuoKihOnJ5_78Fgs0ZrYHlgohmtS6x37TJbDg,556
|
21
|
-
repo_review-0.10.
|
22
|
-
repo_review-0.10.
|
23
|
-
repo_review-0.10.
|
24
|
-
repo_review-0.10.
|
25
|
-
repo_review-0.10.
|
22
|
+
repo_review-0.10.5.dist-info/METADATA,sha256=wExJmbs1_jddrW3WZByFavHXEfF2YVIXkoN9suLE6ng,11370
|
23
|
+
repo_review-0.10.5.dist-info/WHEEL,sha256=osohxoshIHTFJFVPhsi1UkZuLRGMHRXZzwEBW2ezjrc,87
|
24
|
+
repo_review-0.10.5.dist-info/entry_points.txt,sha256=9XaDWanm31NNpXOpjZh2HxSXR5owVdYJ2cbNG5D8wY8,244
|
25
|
+
repo_review-0.10.5.dist-info/licenses/LICENSE,sha256=X7yOxzyAEckYl17p01lZzbraqDVmWEWXE8BnKKRrh7c,1525
|
26
|
+
repo_review-0.10.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|