repo-review 0.11.2__py3-none-any.whl → 0.12.0__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
@@ -34,9 +34,9 @@ from .ghpath import GHPath
34
34
  from .html import to_html
35
35
  from .processor import Result, as_simple_dict, collect_all, process
36
36
 
37
- __all__ = ["main", "Formats", "Show", "Status"]
37
+ __all__ = ["Formats", "Show", "Status", "main"]
38
38
 
39
- CODE_THEME = "default"
39
+ CODE_THEME = "ansi_light"
40
40
 
41
41
 
42
42
  def __dir__() -> list[str]:
@@ -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.2'
16
- __version_tuple__ = version_tuple = (0, 11, 2)
15
+ __version__ = version = '0.12.0'
16
+ __version_tuple__ = version_tuple = (0, 12, 0)
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", "is_allowed", "get_check_url"]
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/fixtures.py CHANGED
@@ -12,11 +12,11 @@ from ._compat.importlib.resources.abc import Traversable
12
12
  from .ghpath import EmptyTraversable
13
13
 
14
14
  __all__ = [
15
- "pyproject",
16
- "list_all",
17
- "compute_fixtures",
18
15
  "apply_fixtures",
19
16
  "collect_fixtures",
17
+ "compute_fixtures",
18
+ "list_all",
19
+ "pyproject",
20
20
  ]
21
21
 
22
22
 
@@ -36,8 +36,7 @@ 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
- # Type ignore fixed in https://github.com/hukkin/tomli/pull/215
40
- return tomllib.load(f) # type: ignore[arg-type]
39
+ return tomllib.load(f)
41
40
  return {}
42
41
 
43
42
 
repo_review/ghpath.py CHANGED
@@ -14,7 +14,7 @@ from typing import Literal
14
14
 
15
15
  from ._compat.importlib.resources.abc import Traversable
16
16
 
17
- __all__ = ["GHPath", "EmptyTraversable"]
17
+ __all__ = ["EmptyTraversable", "GHPath"]
18
18
 
19
19
 
20
20
  def __dir__() -> list[str]:
repo_review/html.py CHANGED
@@ -61,7 +61,7 @@ def to_html(
61
61
  else "red"
62
62
  )
63
63
  icon = (
64
- "⚠️"
64
+ ("🔷" if result.skip_reason else "⚠️")
65
65
  if result.result is None
66
66
  else "✅"
67
67
  if result.result
@@ -79,6 +79,11 @@ def to_html(
79
79
  if result.url
80
80
  else result.description
81
81
  )
82
+ if result.skip_reason:
83
+ description += (
84
+ f'<br/><span style="color:DarkKhaki;"><b>Skipped:</b> '
85
+ f"<em>{md.render(result.skip_reason)}</em></span>"
86
+ )
82
87
  print(f'<tr style="color: {color};">')
83
88
  print(f'<td><span role="img" aria-label="{result_txt}">{icon}</span></td>')
84
89
  print(f'<td nowrap="nowrap">{result.name}</td>')
repo_review/processor.py CHANGED
@@ -17,6 +17,7 @@ from .checks import (
17
17
  collect_checks,
18
18
  get_check_url,
19
19
  is_allowed,
20
+ name_matches,
20
21
  process_result_bool,
21
22
  )
22
23
  from .families import Family, collect_families
@@ -30,8 +31,8 @@ __all__ = [
30
31
  "ResultDict",
31
32
  "as_simple_dict",
32
33
  "collect_all",
33
- "process",
34
34
  "md_as_html",
35
+ "process",
35
36
  ]
36
37
 
37
38
 
@@ -63,6 +64,7 @@ class ResultDict(typing.TypedDict):
63
64
  result: bool | None #: The result, None means skip
64
65
  err_msg: str #: The error message if the result is false, in markdown format
65
66
  url: str #: An optional URL (empty string if missing)
67
+ skip_reason: str #: The reason for the skip, if given (empty string if not)
66
68
 
67
69
 
68
70
  @dataclasses.dataclass(frozen=True, kw_only=True)
@@ -75,6 +77,7 @@ class Result:
75
77
  name: str #: The name of the check
76
78
  description: str #: The short description of what the check looks for
77
79
  result: bool | None #: The result, None means skip
80
+ skip_reason: str = "" #: The reason for the skip, if given
78
81
  err_msg: str = "" #: The error message if the result is false, in markdown format
79
82
  url: str = "" #: An optional URL (empty string if missing)
80
83
 
@@ -179,6 +182,8 @@ def process(
179
182
  *,
180
183
  select: Set[str] = frozenset(),
181
184
  ignore: Set[str] = frozenset(),
185
+ extend_select: Set[str] = frozenset(),
186
+ extend_ignore: Set[str] = frozenset(),
182
187
  subdir: str = "",
183
188
  ) -> ProcessReturn:
184
189
  """
@@ -199,8 +204,12 @@ def process(
199
204
 
200
205
  # Collect our own config
201
206
  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", ()))
207
+ ignore_pyproject: list[str] | dict[str, str] = config.get("ignore", [])
208
+ select_checks = (
209
+ select if select else frozenset(config.get("select", ()))
210
+ ) | extend_select
211
+ skip_checks = (ignore if ignore else frozenset(ignore_pyproject)) | extend_ignore
212
+ skip_reasons = ignore_pyproject if isinstance(ignore_pyproject, dict) else {}
204
213
 
205
214
  # Make a graph of the check's interdependencies
206
215
  graph: dict[str, Set[str]] = {
@@ -234,9 +243,14 @@ def process(
234
243
  result = None if completed[task_name] is None else not completed[task_name]
235
244
  doc = check.__doc__ or ""
236
245
  err_msg = completed[task_name] or ""
246
+ skip_reason = ""
237
247
 
238
248
  if not is_allowed(select_checks, skip_checks, task_name):
239
- continue
249
+ key = name_matches(task_name, skip_reasons.keys())
250
+ if not key or not skip_reasons.get(key, ""):
251
+ continue
252
+ result = None
253
+ skip_reason = skip_reasons[key]
240
254
 
241
255
  result_list.append(
242
256
  Result(
@@ -246,6 +260,7 @@ def process(
246
260
  result=result,
247
261
  err_msg=textwrap.dedent(err_msg),
248
262
  url=get_check_url(task_name, check),
263
+ skip_reason=skip_reason,
249
264
  )
250
265
  )
251
266
 
repo_review/testing.py CHANGED
@@ -13,7 +13,7 @@ from .checks import Check, get_check_url, process_result_bool
13
13
  from .fixtures import apply_fixtures
14
14
  from .processor import Result
15
15
 
16
- __all__ = ["toml_loads", "compute_check"]
16
+ __all__ = ["compute_check", "toml_loads"]
17
17
 
18
18
 
19
19
  def __dir__() -> list[str]:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: repo_review
3
- Version: 0.11.2
3
+ Version: 0.12.0
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,29 +34,6 @@ Provides-Extra: cli
34
34
  Requires-Dist: click>=8; extra == 'cli'
35
35
  Requires-Dist: rich-click; extra == 'cli'
36
36
  Requires-Dist: rich>=12.2; extra == 'cli'
37
- Provides-Extra: dev
38
- Requires-Dist: click>=8; extra == 'dev'
39
- Requires-Dist: pytest>=7; extra == 'dev'
40
- Requires-Dist: rich-click; extra == 'dev'
41
- Requires-Dist: rich>=12.2; extra == 'dev'
42
- Requires-Dist: sp-repo-review>=2024.08.19; extra == 'dev'
43
- Requires-Dist: validate-pyproject>=0.14; extra == 'dev'
44
- Provides-Extra: docs
45
- Requires-Dist: click>=8; extra == 'docs'
46
- Requires-Dist: furo; extra == 'docs'
47
- Requires-Dist: myst-parser>=0.13; extra == 'docs'
48
- Requires-Dist: rich-click; extra == 'docs'
49
- Requires-Dist: rich>=12.2; extra == 'docs'
50
- Requires-Dist: sphinx-autodoc-typehints; extra == 'docs'
51
- Requires-Dist: sphinx-copybutton; extra == 'docs'
52
- Requires-Dist: sphinx-github-changelog; extra == 'docs'
53
- Requires-Dist: sphinx>=4.0; extra == 'docs'
54
- Requires-Dist: sphinxcontrib-programoutput; extra == 'docs'
55
- Requires-Dist: sphinxext-opengraph; extra == 'docs'
56
- Provides-Extra: test
57
- Requires-Dist: pytest>=7; extra == 'test'
58
- Requires-Dist: sp-repo-review>=2024.08.19; extra == 'test'
59
- Requires-Dist: validate-pyproject>=0.14; extra == 'test'
60
37
  Description-Content-Type: text/markdown
61
38
 
62
39
  # repo-review
@@ -125,8 +102,12 @@ select = ["A", "B", "C100"]
125
102
  ignore = ["A100"]
126
103
  ```
127
104
 
105
+ The ignore list can also be a table, with reasons for values.
106
+
128
107
  If `--select` or `--ignore` are given on the command line, they will override
129
- 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.
130
111
 
131
112
  ## Comparison to other frameworks
132
113
 
@@ -159,7 +140,7 @@ webapp. It also would allow `zipfile.Path` to work just as well, too - no need
159
140
  to extract.
160
141
 
161
142
  [Checks][] can request [fixtures][] (like [pytest][]) as arguments. Check files
162
- can add new fixtures as needed. Fixtures are are specified with entry points,
143
+ can add new fixtures as needed. Fixtures are specified with entry points,
163
144
  and take any other fixture as arguments as well - the `root` and `package`
164
145
  fixtures represents the root of the repository and of the package you are
165
146
  checking, respectively, and are the basis for the other fixtures, which are
@@ -195,7 +176,7 @@ collection functions, the family entry-point also supports fixtures.
195
176
  This project inspired [Try-PyHF](https://kratsg.github.io/try-pyhf/), an
196
177
  interface for a High Energy Physics package in Scikit-HEP.
197
178
 
198
- This project inspired [abSENSE](https://princetonuniversity.github.io/abSENSE/), an
179
+ This project inspired [abSENSE](https://princetonuniversity.github.io/abSENSE/), a
199
180
  web interface to abSENSE.
200
181
 
201
182
  This was developed for [Scikit-HEP][] before moving to Scientific-Python.
@@ -1,16 +1,16 @@
1
1
  repo_review/__init__.py,sha256=U03wTpj7PjSsIROp8O4VRG_NVG-plkx14d_MvqpmJ_w,229
2
- repo_review/__main__.py,sha256=FjYamqrS55TYqFvz8TuZdJ5-C-l2QP3_6n8lLH04_8o,13890
3
- repo_review/_version.py,sha256=v52WNNFq-_uq9OSfK9O7vLpi66zlufcyohjNPzWbpdk,413
2
+ repo_review/__main__.py,sha256=-4cUtsnRua2Cwl5ESuBEzXljxWUY2kaAj3kZCFAfwh4,14863
3
+ repo_review/_version.py,sha256=HJyq47ePtlF3WPYAhFFp5LPsrHyF6oju_vSEfklwWro,413
4
4
  repo_review/_version.pyi,sha256=j5kbzfm6lOn8BzASXWjGIA1yT0OlHTWqlbyZ8Si_o0E,118
5
- repo_review/checks.py,sha256=SzTnMxj756xMb9Rffl9K65o2rUGDYfG6CQCj-pNWQzk,4316
5
+ repo_review/checks.py,sha256=Iz5T1d0wDfBIyaO3f5waHEqhmfP_4-9eNOngJpRnpGo,4845
6
6
  repo_review/families.py,sha256=TEMQY3whMj8b3iVlWyVsTa0CAZexXRCFXq5uPIkV6bs,2389
7
- repo_review/fixtures.py,sha256=AHdUhDU--SOrlhWSymiyECp5LmaCGYNRcZHuPpzFUts,3709
8
- repo_review/ghpath.py,sha256=YadsOkd2hGOrDffSU3PtQiDLgvrVe1GuMKeDFKXwtLs,6123
9
- repo_review/html.py,sha256=LwoZUqiWC84qSuhwbzqQtwhWDhE8JiPWWTI4nKXF3nA,3485
10
- repo_review/processor.py,sha256=txXKyw1VP31sclfQL0yac5mXYTkFoca3t-3yKBvqc5k,8275
7
+ repo_review/fixtures.py,sha256=ypeEj-Ae3_3bUWUE0n-wuOrKlEVFU6rp7zK-UoC_t6E,3607
8
+ repo_review/ghpath.py,sha256=fkzUD1G_kuzCmVhTH2yAJoJxxYwjAXfjnBwtaj6nqg0,6123
9
+ repo_review/html.py,sha256=XGfWXNkYK4jQT3KiQRGC4wnhv-DLG-JKttSkqVr7uIM,3759
10
+ repo_review/processor.py,sha256=-p70iGbqwy6Tw-FxxIAXUlgXQxk74fvLQXmojunqikU,8984
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=qbjevlG_DQbL4-l-7wTM9rqoLvRaxf7GF66D8i723OY,1915
13
+ repo_review/testing.py,sha256=tA0c-baQ2-0UQMKnY59NgBuLmBqsVcFUBP4uYsL3n6Q,1915
14
14
  repo_review/_compat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  repo_review/_compat/tomllib.py,sha256=caR8Mj-hSBLE2zqdLLjzwOdCBOfikVqS8pWkc4K5vgc,233
16
16
  repo_review/_compat/typing.py,sha256=vXfYiJHUaqMShRMbJi0VUg2V59UV-oxceZKSBZ3tfts,246
@@ -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.2.dist-info/METADATA,sha256=uCkBoPbRRxwzV-ZqOj070MBQiZL5sh4E3l7ENJhgs9M,11437
23
- repo_review-0.11.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
24
- repo_review-0.11.2.dist-info/entry_points.txt,sha256=9XaDWanm31NNpXOpjZh2HxSXR5owVdYJ2cbNG5D8wY8,244
25
- repo_review-0.11.2.dist-info/licenses/LICENSE,sha256=X7yOxzyAEckYl17p01lZzbraqDVmWEWXE8BnKKRrh7c,1525
26
- repo_review-0.11.2.dist-info/RECORD,,
22
+ repo_review-0.12.0.dist-info/METADATA,sha256=duKtaL0RIK1pxVs5iH8HQZ3vivRwDjzCKdV4SWJPqH8,10613
23
+ repo_review-0.12.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
+ repo_review-0.12.0.dist-info/entry_points.txt,sha256=9XaDWanm31NNpXOpjZh2HxSXR5owVdYJ2cbNG5D8wY8,244
25
+ repo_review-0.12.0.dist-info/licenses/LICENSE,sha256=X7yOxzyAEckYl17p01lZzbraqDVmWEWXE8BnKKRrh7c,1525
26
+ repo_review-0.12.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any