repo-review 0.11.3__py3-none-any.whl → 0.12.1__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/__main__.py CHANGED
@@ -163,6 +163,13 @@ def rich_printer(
163
163
  msg.append(rich.text.Text.from_markup(description, style=style))
164
164
  if result.result is None:
165
165
  msg.append(" [skipped]", style="yellow bold")
166
+ if result.skip_reason:
167
+ sr_style = "yellow"
168
+ msg.append(" (", style=sr_style)
169
+ msg.append(
170
+ rich.text.Text.from_markup(result.skip_reason, style=sr_style)
171
+ )
172
+ msg.append(")", style=sr_style)
166
173
  tree.add(msg)
167
174
  elif result.result:
168
175
  msg.append(rich.text.Text.from_markup(" :white_check_mark:"))
@@ -315,6 +322,16 @@ def _remote_path_processor(package: Path) -> Path | GHPath:
315
322
  help="Ignore a check or checks, comma separated.",
316
323
  default="",
317
324
  )
325
+ @click.option(
326
+ "--extend-select",
327
+ help="Checks to run in addition to the ones selected.",
328
+ default="",
329
+ )
330
+ @click.option(
331
+ "--extend-ignore",
332
+ help="Checks to ignore in addition to the ones ignored.",
333
+ default="",
334
+ )
318
335
  @click.option(
319
336
  "--package-dir",
320
337
  "-p",
@@ -327,6 +344,8 @@ def main(
327
344
  stderr_fmt: Formats | None,
328
345
  select: str,
329
346
  ignore: str,
347
+ extend_select: str,
348
+ extend_ignore: str,
330
349
  package_dir: str,
331
350
  show: Show,
332
351
  ) -> None:
@@ -351,6 +370,8 @@ def main(
351
370
  stderr_fmt,
352
371
  select,
353
372
  ignore,
373
+ extend_select,
374
+ extend_ignore,
354
375
  package_dir,
355
376
  add_header=len(packages) > 1,
356
377
  show=show,
@@ -378,6 +399,8 @@ def on_each(
378
399
  stderr_fmt: Literal["rich", "json", "html", "svg"] | None,
379
400
  select: str,
380
401
  ignore: str,
402
+ extend_select: str,
403
+ extend_ignore: str,
381
404
  package_dir: str,
382
405
  *,
383
406
  add_header: bool,
@@ -387,6 +410,8 @@ def on_each(
387
410
 
388
411
  ignore_list = {x.strip() for x in ignore.split(",") if x}
389
412
  select_list = {x.strip() for x in select.split(",") if x}
413
+ extend_ignore_list = {x.strip() for x in extend_ignore.split(",") if x}
414
+ extend_select_list = {x.strip() for x in extend_select.split(",") if x}
390
415
 
391
416
  collected = collect_all(package, subdir=package_dir)
392
417
  if len(collected.checks) == 0:
@@ -407,7 +432,12 @@ def on_each(
407
432
  header = package.name
408
433
 
409
434
  families, processed = process(
410
- base_package, select=select_list, ignore=ignore_list, subdir=package_dir
435
+ base_package,
436
+ select=select_list,
437
+ ignore=ignore_list,
438
+ extend_select=extend_select_list,
439
+ extend_ignore=extend_ignore_list,
440
+ subdir=package_dir,
411
441
  )
412
442
 
413
443
  status: Status = "passed" if processed else "empty"
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.11.3'
16
- __version_tuple__ = version_tuple = (0, 11, 3)
15
+ __version__ = version = '0.12.1'
16
+ __version_tuple__ = version_tuple = (0, 12, 1)
repo_review/checks.py CHANGED
@@ -6,7 +6,7 @@ from typing import Any, Protocol
6
6
 
7
7
  from .fixtures import apply_fixtures
8
8
 
9
- __all__ = ["Check", "collect_checks", "get_check_url", "is_allowed"]
9
+ __all__ = ["Check", "collect_checks", "get_check_url", "is_allowed", "name_matches"]
10
10
 
11
11
 
12
12
  def __dir__() -> list[str]:
@@ -70,6 +70,25 @@ def collect_checks(fixtures: Mapping[str, Any]) -> dict[str, Check]:
70
70
  }
71
71
 
72
72
 
73
+ def name_matches(name: str, selectors: Set[str]) -> str:
74
+ """
75
+ Checks if the name is contained in the matchers. The selectors can be the
76
+ exact name or just the non-number prefix. Returns the selector that matched,
77
+ or an empty string if no match.
78
+
79
+ :param name: The name to check.
80
+ :param expr: The expression to check against.
81
+
82
+ :return: The matched selector if the name matches a selector, or an empty string if no match.
83
+ """
84
+ if name in selectors:
85
+ return name
86
+ short_name = name.rstrip("0123456789")
87
+ if short_name in selectors:
88
+ return short_name
89
+ return ""
90
+
91
+
73
92
  def is_allowed(select: Set[str], ignore: Set[str], name: str) -> bool:
74
93
  """
75
94
  Skips the check if the name is in the ignore list or if the name without the
@@ -82,15 +101,10 @@ def is_allowed(select: Set[str], ignore: Set[str], name: str) -> bool:
82
101
 
83
102
  :return: True if this check is allowed, False otherwise.
84
103
  """
85
- if (
86
- select
87
- and name not in select
88
- and name.rstrip("0123456789") not in select
89
- and "*" not in select
90
- ):
104
+ if select and not name_matches(name, select) and "*" not in select:
91
105
  return False
92
106
 
93
- return name not in ignore and name.rstrip("0123456789") not in ignore
107
+ return not name_matches(name, ignore)
94
108
 
95
109
 
96
110
  def get_check_url(name: str, check: Check) -> str:
repo_review/html.py CHANGED
@@ -6,10 +6,8 @@ import io
6
6
  import typing
7
7
  from collections.abc import Mapping, Sequence
8
8
 
9
- import markdown_it
10
-
11
9
  from .families import Family, get_family_description, get_family_name
12
- from .processor import Result
10
+ from .processor import Result, md_as_html
13
11
 
14
12
  if typing.TYPE_CHECKING:
15
13
  from .__main__ import Status
@@ -37,16 +35,15 @@ def to_html(
37
35
  """
38
36
  out = io.StringIO()
39
37
  print = functools.partial(builtins.print, file=out)
40
- md = markdown_it.MarkdownIt()
41
38
 
42
39
  for family in families:
43
40
  family_name = get_family_name(families, family)
44
41
  family_description = get_family_description(families, family)
45
- family_results = [r for r in processed if r.family == family]
42
+ family_results = [r.md_as_html() for r in processed if r.family == family]
46
43
  if family_results or family_description:
47
44
  print(f"<h3>{family_name}</h3>")
48
45
  if family_description:
49
- print(md.render(family_description).strip())
46
+ print("<p>", md_as_html(family_description), "</p>")
50
47
  if family_results:
51
48
  print("<table>")
52
49
  print(
@@ -61,7 +58,7 @@ def to_html(
61
58
  else "red"
62
59
  )
63
60
  icon = (
64
- "&#9888;&#65039;"
61
+ ("&#128311;" if result.skip_reason else "&#9888;&#65039;")
65
62
  if result.result is None
66
63
  else "&#9989;"
67
64
  if result.result
@@ -79,6 +76,11 @@ def to_html(
79
76
  if result.url
80
77
  else result.description
81
78
  )
79
+ if result.skip_reason:
80
+ description += (
81
+ f'<br/><span style="color:DarkKhaki;"><b>Skipped:</b> '
82
+ f"<em>{result.skip_reason}</em></span>"
83
+ )
82
84
  print(f'<tr style="color: {color};">')
83
85
  print(f'<td><span role="img" aria-label="{result_txt}">{icon}</span></td>')
84
86
  print(f'<td nowrap="nowrap">{result.name}</td>')
@@ -88,7 +90,7 @@ def to_html(
88
90
  print("<td>")
89
91
  print(description)
90
92
  print("<br/>")
91
- print(md.render(result.err_msg))
93
+ print(result.err_msg)
92
94
  print("</td>")
93
95
  print("</tr>")
94
96
  if family_results:
repo_review/processor.py CHANGED
@@ -3,11 +3,12 @@ from __future__ import annotations
3
3
  import copy
4
4
  import dataclasses
5
5
  import graphlib
6
+ import sys
6
7
  import textwrap
7
8
  import typing
8
9
  import warnings
9
10
  from collections.abc import Mapping, Set
10
- from typing import Any, TypeVar
11
+ from typing import TYPE_CHECKING, Any, TypeVar
11
12
 
12
13
  import markdown_it
13
14
 
@@ -17,12 +18,19 @@ from .checks import (
17
18
  collect_checks,
18
19
  get_check_url,
19
20
  is_allowed,
21
+ name_matches,
20
22
  process_result_bool,
21
23
  )
22
24
  from .families import Family, collect_families
23
25
  from .fixtures import apply_fixtures, collect_fixtures, compute_fixtures, pyproject
24
26
  from .ghpath import EmptyTraversable
25
27
 
28
+ if TYPE_CHECKING:
29
+ if sys.version_info >= (3, 11):
30
+ from typing import Self
31
+ else:
32
+ from typing_extensions import Self
33
+
26
34
  __all__ = [
27
35
  "CollectionReturn",
28
36
  "ProcessReturn",
@@ -63,6 +71,7 @@ class ResultDict(typing.TypedDict):
63
71
  result: bool | None #: The result, None means skip
64
72
  err_msg: str #: The error message if the result is false, in markdown format
65
73
  url: str #: An optional URL (empty string if missing)
74
+ skip_reason: str #: The reason for the skip, if given (empty string if not)
66
75
 
67
76
 
68
77
  @dataclasses.dataclass(frozen=True, kw_only=True)
@@ -75,15 +84,29 @@ class Result:
75
84
  name: str #: The name of the check
76
85
  description: str #: The short description of what the check looks for
77
86
  result: bool | None #: The result, None means skip
87
+ skip_reason: str = "" #: The reason for the skip, if given
78
88
  err_msg: str = "" #: The error message if the result is false, in markdown format
79
89
  url: str = "" #: An optional URL (empty string if missing)
80
90
 
81
91
  def err_as_html(self) -> str:
82
92
  """
83
93
  Produces HTML from the error message, assuming it is in markdown.
94
+ Deprecated, use :meth:`md_as_html` directly instead.
84
95
  """
85
96
  return md_as_html(self.err_msg)
86
97
 
98
+ def md_as_html(self) -> Self:
99
+ """
100
+ Process fields that are assumed to be markdown.
101
+
102
+ .. versionadded:: 0.12.1
103
+ """
104
+ return dataclasses.replace(
105
+ self,
106
+ err_msg=md_as_html(self.err_msg),
107
+ skip_reason=md_as_html(self.skip_reason),
108
+ )
109
+
87
110
 
88
111
  class ProcessReturn(typing.NamedTuple):
89
112
  """
@@ -179,6 +202,8 @@ def process(
179
202
  *,
180
203
  select: Set[str] = frozenset(),
181
204
  ignore: Set[str] = frozenset(),
205
+ extend_select: Set[str] = frozenset(),
206
+ extend_ignore: Set[str] = frozenset(),
182
207
  subdir: str = "",
183
208
  ) -> ProcessReturn:
184
209
  """
@@ -199,8 +224,12 @@ def process(
199
224
 
200
225
  # Collect our own config
201
226
  config = pyproject(package).get("tool", {}).get("repo-review", {})
202
- select_checks = select if select else frozenset(config.get("select", ()))
203
- skip_checks = ignore if ignore else frozenset(config.get("ignore", ()))
227
+ ignore_pyproject: list[str] | dict[str, str] = config.get("ignore", [])
228
+ select_checks = (
229
+ select if select else frozenset(config.get("select", ()))
230
+ ) | extend_select
231
+ skip_checks = (ignore if ignore else frozenset(ignore_pyproject)) | extend_ignore
232
+ skip_reasons = ignore_pyproject if isinstance(ignore_pyproject, dict) else {}
204
233
 
205
234
  # Make a graph of the check's interdependencies
206
235
  graph: dict[str, Set[str]] = {
@@ -234,9 +263,14 @@ def process(
234
263
  result = None if completed[task_name] is None else not completed[task_name]
235
264
  doc = check.__doc__ or ""
236
265
  err_msg = completed[task_name] or ""
266
+ skip_reason = ""
237
267
 
238
268
  if not is_allowed(select_checks, skip_checks, task_name):
239
- continue
269
+ key = name_matches(task_name, skip_reasons.keys())
270
+ if not key or not skip_reasons.get(key, ""):
271
+ continue
272
+ result = None
273
+ skip_reason = skip_reasons[key]
240
274
 
241
275
  result_list.append(
242
276
  Result(
@@ -246,6 +280,7 @@ def process(
246
280
  result=result,
247
281
  err_msg=textwrap.dedent(err_msg),
248
282
  url=get_check_url(task_name, check),
283
+ skip_reason=skip_reason,
249
284
  )
250
285
  )
251
286
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: repo_review
3
- Version: 0.11.3
3
+ Version: 0.12.1
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
@@ -8,6 +8,7 @@ Project-URL: Documentation, https://repo-review.readthedocs.io
8
8
  Project-URL: Homepage, https://repo-review.readthedocs.io
9
9
  Project-URL: Source, https://github.com/scientific-python/repo-review
10
10
  Author-email: Henry Schreiner <henryfs@princeton.edu>
11
+ License-File: LICENSE
11
12
  Classifier: Development Status :: 4 - Beta
12
13
  Classifier: Environment :: Console
13
14
  Classifier: Environment :: WebAssembly :: Emscripten
@@ -101,8 +102,12 @@ select = ["A", "B", "C100"]
101
102
  ignore = ["A100"]
102
103
  ```
103
104
 
105
+ The ignore list can also be a table, with reasons for values.
106
+
104
107
  If `--select` or `--ignore` are given on the command line, they will override
105
- the `pyproject.toml` config.
108
+ the `pyproject.toml` config. You can use `--extend-select` and `--extend-ignore`
109
+ on the command line to extend the `pyproject.toml` config. These CLI options
110
+ are comma separated.
106
111
 
107
112
  ## Comparison to other frameworks
108
113
 
@@ -1,13 +1,13 @@
1
1
  repo_review/__init__.py,sha256=U03wTpj7PjSsIROp8O4VRG_NVG-plkx14d_MvqpmJ_w,229
2
- repo_review/__main__.py,sha256=dXejLf8wJ6spTr_RdL-o_EqdZEQ0CfEteA7PB7m2b-M,13893
3
- repo_review/_version.py,sha256=OkAeaAqw1G6xdcg59fk8Mamyqb2RLX_cARtBOHOICIM,413
2
+ repo_review/__main__.py,sha256=-4cUtsnRua2Cwl5ESuBEzXljxWUY2kaAj3kZCFAfwh4,14863
3
+ repo_review/_version.py,sha256=OSJc7-JxViAvW4SmGUZQQX05ZpGw9KopFINBSBZ_tHs,413
4
4
  repo_review/_version.pyi,sha256=j5kbzfm6lOn8BzASXWjGIA1yT0OlHTWqlbyZ8Si_o0E,118
5
- repo_review/checks.py,sha256=U1MyA_esE-AjzMfjzSZd0C0XHDZ1UtLXQXebXnaUers,4316
5
+ repo_review/checks.py,sha256=Iz5T1d0wDfBIyaO3f5waHEqhmfP_4-9eNOngJpRnpGo,4845
6
6
  repo_review/families.py,sha256=TEMQY3whMj8b3iVlWyVsTa0CAZexXRCFXq5uPIkV6bs,2389
7
7
  repo_review/fixtures.py,sha256=ypeEj-Ae3_3bUWUE0n-wuOrKlEVFU6rp7zK-UoC_t6E,3607
8
8
  repo_review/ghpath.py,sha256=fkzUD1G_kuzCmVhTH2yAJoJxxYwjAXfjnBwtaj6nqg0,6123
9
- repo_review/html.py,sha256=LwoZUqiWC84qSuhwbzqQtwhWDhE8JiPWWTI4nKXF3nA,3485
10
- repo_review/processor.py,sha256=pPAj2kdUFoXAMB3Hqe9VbNlwCs20OK0ODJrE1VaMyaI,8275
9
+ repo_review/html.py,sha256=Mazyng90X31DTOk23ZKtIMwyN-LeHnwG7StwdySwMAA,3716
10
+ repo_review/processor.py,sha256=Cfw65EGfFQosLh6g1jeghWR0xTIg0HRpXXJVsCpiqX0,9524
11
11
  repo_review/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  repo_review/schema.py,sha256=U_iox0khN1oEHCCB5ILffjRvZLG7BR-aaip9QEpMkJk,593
13
13
  repo_review/testing.py,sha256=tA0c-baQ2-0UQMKnY59NgBuLmBqsVcFUBP4uYsL3n6Q,1915
@@ -19,8 +19,8 @@ repo_review/_compat/importlib/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5J
19
19
  repo_review/_compat/importlib/resources/abc.py,sha256=KLv7AqUaY-ezZ32lA5yVcZLfMqY6VEo8Q-1jyWpGRbk,300
20
20
  repo_review/resources/__init__.py,sha256=RBBaUp-hQrIYBqbAT0MytCXEjDmqVsCjiEgdK_K3dN4,138
21
21
  repo_review/resources/repo-review.schema.json,sha256=jAc7ZQV-Hc16ENrNFZm7nlIjiRQGTanq8EjBICkJKpE,791
22
- repo_review-0.11.3.dist-info/METADATA,sha256=svwJcOBrhYYwZmdGKGI1rFcLKKRApKPlSCaJW5sE9wk,10378
23
- repo_review-0.11.3.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
24
- repo_review-0.11.3.dist-info/entry_points.txt,sha256=9XaDWanm31NNpXOpjZh2HxSXR5owVdYJ2cbNG5D8wY8,244
25
- repo_review-0.11.3.dist-info/licenses/LICENSE,sha256=X7yOxzyAEckYl17p01lZzbraqDVmWEWXE8BnKKRrh7c,1525
26
- repo_review-0.11.3.dist-info/RECORD,,
22
+ repo_review-0.12.1.dist-info/METADATA,sha256=usuR22S6tkCFLYZ04RoX0v4WaXXgFVCdHUBNi_sS4ho,10613
23
+ repo_review-0.12.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
+ repo_review-0.12.1.dist-info/entry_points.txt,sha256=9XaDWanm31NNpXOpjZh2HxSXR5owVdYJ2cbNG5D8wY8,244
25
+ repo_review-0.12.1.dist-info/licenses/LICENSE,sha256=X7yOxzyAEckYl17p01lZzbraqDVmWEWXE8BnKKRrh7c,1525
26
+ repo_review-0.12.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.26.3
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any