repo_review package¶
Copyright (c) 2022 Henry Schreiner. All rights reserved.
Review repos with a set of checks defined by plugins.
Subpackages¶
Submodules¶
repo_review.checks module¶
- class repo_review.checks.Check(*args, **kwargs)[source]¶
Bases:
Protocol
This is the check Protocol. Since Python doesn’t support optional Protocol members, the two optional members are required if you want to use this Protocol in a type checker. The members can be specified as class properties if you want.
- check()[source]¶
This is a check. The docstring is used as the failure message if False is returned. Returning None is a skip. Returning True (or an empty string) is a pass. Can be a
classmethod()
orstaticmethod()
. Can take fixtures.
- repo_review.checks.collect_checks(fixtures)[source]¶
Produces a list of checks based on installed entry points. You must provide the evaluated fixtures so that the check functions have access to the fixtures when they are running.
- repo_review.checks.get_check_url(name, check)[source]¶
Get the url from a check instance. Will return an empty string if missing. Will process string via format.
- Parameters:
- Return type:
- Returns:
The final URL.
Added in version 0.8.
repo_review.families module¶
- class repo_review.families.Family[source]¶
Bases:
TypedDict
A typed Dict that is used to customize the display of families in reports.
- repo_review.families.collect_families(fixtures)[source]¶
Produces a dict mapping family keys to
Family
dicts based on installed entry points. You must provide the evaluated fixtures so that the family functions have access to the fixtures when they are running, usually used for descriptions.
repo_review.fixtures module¶
- repo_review.fixtures.apply_fixtures(fixtures, func)[source]¶
Given the pre-computed dict of fixtures and a function, fill in any fixtures from that dict that it requests and return the result.
- repo_review.fixtures.collect_fixtures()[source]¶
Produces a dict of fixture callables based on installed entry points. You should call
compute_fixtures()
on the result to get the standard dict of fixture results that most other functions in repo-review expect.- Return type:
dict
[str
,Callable
[[Traversable
],Any
]]- Returns:
A dict of unevaluated fixtures.
- repo_review.fixtures.compute_fixtures(root, package, unevaluated_fixtures)[source]¶
Given the repo
root
Traversable, thepackage
Traversable, and the dict of all fixture callables, compute the dict of fixture results.- Parameters:
root (
Traversable
) – The root of the repositorypackage (
Traversable
) – The path to the package (root / subdir
)unevaluated_fixtures (
Mapping
[str
,Callable
[...
,Any
]]) – The unevaluated mapping of fixture names to callables.
- Return type:
- Returns:
The fully evaluated dict of fixtures.
- repo_review.fixtures.list_all(root)[source]¶
Fixture: Is True when this is trying to produce a list of all checks.
- Parameters:
root (
Traversable
) – The root fixture.- Return type:
- Returns:
True only if trying to make a list of all checks/fixtures/families.
Added in version 0.8.
- repo_review.fixtures.pyproject(package)[source]¶
Fixture: The
pyproject.toml
structure from the package. Returned an empty dict if no pyproject.toml found.- Parameters:
package (
Traversable
) – The package fixture.- Return type:
- Returns:
The pyproject.toml dict or an empty dict if no file found.
repo_review.ghpath module¶
- class repo_review.ghpath.EmptyTraversable(*, is_a_dir=True, _fake_name='not-a-real-path')[source]¶
Bases:
Traversable
This is a Traversable representing an empty directory or a non-existent file.
- Parameters:
- joinpath(child)[source]¶
Return Traversable resolved with any descendants applied.
Each descendant should be a path segment relative to self and each may contain multiple levels separated by
posixpath.sep
(/
).- Parameters:
child (
str
)- Return type:
- class repo_review.ghpath.GHPath(*, repo, branch, path='', _info=<factory>)[source]¶
Bases:
Traversable
This is a Traversable that can be used to navigate a GitHub repo without downloading it.
- Parameters:
- joinpath(child)[source]¶
Return Traversable resolved with any descendants applied.
Each descendant should be a path segment relative to self and each may contain multiple levels separated by
posixpath.sep
(/
).
- open(mode='r', encoding='utf-8')[source]¶
Open the repo. This doesn’t support the full collection of options, only utf-8 and binary.
- static open_url(url)[source]¶
This method can be overridden manually for WASM. Supports pyodide currently.
repo_review.html module¶
- repo_review.html.to_html(families, processed, status='empty')[source]¶
Convert the results of a repo review (
families
,processed
) to HTML.- Parameters:
- Return type:
repo_review.processor module¶
- class repo_review.processor.CollectionReturn(fixtures: dict[str, Any], checks: dict[str, Check], families: dict[str, Family])[source]¶
Bases:
NamedTuple
Return type for
collect_all()
.Added in version 0.8.
- class repo_review.processor.ProcessReturn(families: dict[str, Family], results: list[Result])[source]¶
Bases:
NamedTuple
Return type for
process()
.
- class repo_review.processor.Result(*, family, name, description, result, err_msg='', url='')[source]¶
Bases:
object
This is the returned value from a processed check.
- class repo_review.processor.ResultDict[source]¶
Bases:
TypedDict
Helper to get the type in the JSON style returns. Basically identical to
Result
but in dict form and without the name.
- repo_review.processor.as_simple_dict(results)[source]¶
Convert a results list into a simple dict of dicts structure. The name of the result turns into the key of the outer dict.
- Parameters:
- Return type:
- repo_review.processor.collect_all(root=EmptyTraversable(is_a_dir=True, _fake_name='not-a-real-path'), subdir='')[source]¶
Collect all checks. If
root
is not passed, then checks are collected with aEmptyTraversable
. Any checks that are returned conditionally based on fixture results might not be collected unlesslist_all()
is used.- Parameters:
root (
Traversable
) – If passed, this is the root of the repo (for fixture computation).subdir (
str
) – The subdirectory (for fixture computation).
- Return type:
- Returns:
The collected fixtures, checks, and families. Families is guaranteed to include all families and be in order.
Added in version 0.8.
- repo_review.processor.md_as_html(md_text)[source]¶
Heler function that converts markdown text to HTML. Strips paragraph tags from the result.
repo_review.schema module¶
This accesses the schema for repo-review’s tool section.
repo_review.testing module¶
Helpers for testing repo-review plugins.
- repo_review.testing.compute_check(name, /, **fixtures)[source]¶
A helper function to compute a check given fixtures, intended for testing. Currently, all fixtures are required to be passed in as keyword arguments, transitive fixtures are not supported.
- Parameters:
- Return type:
- Returns:
The computed result.
Added in version 0.10.5.