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 CHANGED
@@ -4,7 +4,6 @@ Copyright (c) 2022 Henry Schreiner. All rights reserved.
4
4
  Review repos with a set of checks defined by plugins.
5
5
  """
6
6
 
7
-
8
7
  from __future__ import annotations
9
8
 
10
9
  from ._version import version as __version__
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(suppress=[click, rich, orig_click], show_locals=True, width=None)
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(family_description)
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
 
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import sys
4
4
 
5
5
  if sys.version_info < (3, 11):
6
+ # pylint: disable-next=deprecated-class
6
7
  from importlib.abc import Traversable
7
8
  else:
8
9
  from importlib.resources.abc import Traversable
repo_review/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.10.3'
16
- __version_tuple__ = version_tuple = (0, 10, 3)
15
+ __version__ = version = '0.10.5'
16
+ __version_tuple__ = version_tuple = (0, 10, 5)
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
- return tomllib.load(f)
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 Check, collect_checks, get_check_url, is_allowed
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
- if isinstance(result, bool):
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
1
+ Metadata-Version: 2.3
2
2
  Name: repo_review
3
- Version: 0.10.3
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: repo-review[cli,test]; extra == 'dev'
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: repo-review[cli]; extra == 'docs'
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=Mwl2Lp046LmlrYhaYX-_krbiWhPG5VLFHVrDvSTtnq8,230
2
- repo_review/__main__.py,sha256=4lCgZAS4dz4n4VTJjoNtI6XpvB42ShBHsZp6M0-dLDg,12155
3
- repo_review/_version.py,sha256=SKb0TTd5WAJtPD1U3WP3U2LAReDzz1-8GhfDHJX-1HA,413
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=TH6a7_Kbwig6yme8sRv-dKi4RoeaJ1w9WMO6lSTi4-M,3711
5
+ repo_review/checks.py,sha256=hIwQARm0JESf0yMCfjR5jaI-AdnCO7ePTY28eQ2iOy4,4340
6
6
  repo_review/families.py,sha256=TEMQY3whMj8b3iVlWyVsTa0CAZexXRCFXq5uPIkV6bs,2389
7
- repo_review/fixtures.py,sha256=gSWQuROF-FLBvu4Wmjf_1FzyQDZWzTFFfeJEusk8Cg8,3607
8
- repo_review/ghpath.py,sha256=CArlWT4yNgIIoDZ4pVNxucmAdUUMkJSkkROtk35q5qc,6010
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=qVju2d1DUSFBHnHb1S7obICMBqIIjSj1stQSe9H7P1Q,8196
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=0DXPlrQLCeUNTmY2ex5FlR8_T3FfNllfvVF8n2-ta9w,256
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.3.dist-info/METADATA,sha256=338CWsGts758GpvCsL8iauTx4XUl6cAPlX5npv4RqtU,10748
22
- repo_review-0.10.3.dist-info/WHEEL,sha256=mRYSEL3Ih6g5a_CVMIcwiF__0Ae4_gLYh01YFNwiq1k,87
23
- repo_review-0.10.3.dist-info/entry_points.txt,sha256=9XaDWanm31NNpXOpjZh2HxSXR5owVdYJ2cbNG5D8wY8,244
24
- repo_review-0.10.3.dist-info/licenses/LICENSE,sha256=X7yOxzyAEckYl17p01lZzbraqDVmWEWXE8BnKKRrh7c,1525
25
- repo_review-0.10.3.dist-info/RECORD,,
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,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.21.0
2
+ Generator: hatchling 1.24.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any