rosdistro_reviewer package

Subpackages

Submodules

rosdistro_reviewer.command module

rosdistro_reviewer.command.LOG_LEVEL_ENVIRONMENT_VARIABLE = ('ROSDISTRO_REVIEWER_LOG_LEVEL', 'Set the log level (debug|10, info|20, warn|30, error|40, critical|50, or any other positive numeric value)')

Environment variable to set the configuration directory

rosdistro_reviewer.command.main(*args: str, **kwargs: str) Any

Execute the main logic of the command.

rosdistro_reviewer.git_lines module

rosdistro_reviewer.git_lines.get_added_lines(path, *, target_ref: str | None = None, head_ref: str | None = None, paths=None) Mapping[str, Sequence[range]] | None

Determine what lines were added between two git repository states.

Parameters:
  • path – The path to the repository root

  • target_ref – The git ref to base the diff from

  • head_ref – The git ref where the changes have been made

  • paths – Relative paths under the repository to limit results to

Returns:

Mapping of relative file paths to sequences of line number ranges, or None if no changes were detected

rosdistro_reviewer.review module

class rosdistro_reviewer.review.Annotation(file, lines, message)

Bases: tuple

file

Alias for field number 0

lines

Alias for field number 1

message

Alias for field number 2

class rosdistro_reviewer.review.Criterion(recommendation, rationale)

Bases: tuple

rationale

Alias for field number 1

recommendation

Alias for field number 0

class rosdistro_reviewer.review.Recommendation(*values)

Bases: IntEnum

Singular recommendations a review can make.

APPROVE = 2
DISAPPROVE = 0
NEUTRAL = 1
as_symbol() str

Convert the recommendation to a unicode symbol.

as_text() str

Convert the recommendation to a shot text summary.

class rosdistro_reviewer.review.Review

Bases: object

High-level representation of a rosdistro code review.

property annotations: List[Annotation]

Get the list of code annotations.

property elements: Dict[str, List[Criterion]]

Get the mapping of element name to criteria collection.

property recommendation: Recommendation

Get the overall review recommendation.

summarize() str

Summarize the review elements.

to_text(*, width: int = 80, root: Path | None = None) str

Generate a text representation of this review.

Parameters:
  • width – Maximum number of columns in the output.

  • root – Path to where code annotations can be resolved to. Used to prepend annotations with snippets of the code they refer to.

Returns:

A string containing the text representation of the review.

rosdistro_reviewer.yaml_changes module

rosdistro_reviewer.yaml_changes.get_changed_yaml(path, paths, *, target_ref: str | None = None, head_ref: str | None = None) Mapping[str, Any] | None

Load YAML data with line annotations only on changed trees.

Parameters:
  • path – Path on disk to the git repository

  • paths – Repository-relative paths to YAML files to look for changes to

  • target_ref – The git ref to base the diff from

  • head_ref – The git ref where the changes have been made

Returns:

Mapping of YAML file paths to annotated YAML data, or None if no changes were detected

rosdistro_reviewer.yaml_changes.prune_changed_yaml(data: Any) None

Prune sub-trees of annotated YAML data without line annotations.

Parameters:

data – The YAML data to prune

Returns:

None

rosdistro_reviewer.yaml_lines module

class rosdistro_reviewer.yaml_lines.AnnotatedSafeLoader(stream)

Bases: SafeLoader

YAML loader that adds __lines__ attributes to some of the parsed data.

This extension of the PyYAML SafeLoader replaces some basic types with derived types that include a __lines__ attribute to determine where the deserialized data can be found in the YAML file it was parsed from.

class AnnotatedDict(*args, **kwargs)

Bases: dict

Implementation of dict with __lines__ attribute.

class AnnotatedList(*args, **kwargs)

Bases: list

Implementation of list with __lines__ attribute.

class AnnotatedStr(*args, **kwargs)

Bases: str

Implementation of str with __lines__ attribute.

compose_node(parent, index)
construct_annotated_map(node)
construct_annotated_seq(node)
construct_annotated_str(node)
yaml_constructors = {'tag:yaml.org,2002:binary': <function SafeConstructor.construct_yaml_binary>, 'tag:yaml.org,2002:bool': <function SafeConstructor.construct_yaml_bool>, 'tag:yaml.org,2002:float': <function SafeConstructor.construct_yaml_float>, 'tag:yaml.org,2002:int': <function SafeConstructor.construct_yaml_int>, 'tag:yaml.org,2002:map': <function AnnotatedSafeLoader.construct_annotated_map>, 'tag:yaml.org,2002:null': <function SafeConstructor.construct_yaml_null>, 'tag:yaml.org,2002:omap': <function SafeConstructor.construct_yaml_omap>, 'tag:yaml.org,2002:pairs': <function SafeConstructor.construct_yaml_pairs>, 'tag:yaml.org,2002:seq': <function AnnotatedSafeLoader.construct_annotated_seq>, 'tag:yaml.org,2002:set': <function SafeConstructor.construct_yaml_set>, 'tag:yaml.org,2002:str': <function AnnotatedSafeLoader.construct_annotated_str>, 'tag:yaml.org,2002:timestamp': <function SafeConstructor.construct_yaml_timestamp>, None: <function SafeConstructor.construct_undefined>}

Module contents