lookout.style.format.annotations.annotations

Annotations for style-analyzer.

Module Contents

lookout.style.format.annotations.annotations.check_offset(value:Union[int, numpy.int], name:str)

Validate the offset: check the type and reject negative values.

Parameters:
  • value – Offset value to check.
  • name – Variable name for the exception message.
Raises:

ValueError – if value is incorrect.

lookout.style.format.annotations.annotations.check_span(start:int, stop:int)

Validate span value: check the type, reject negative values and ensure an increasing order.

Parameters:
  • start – Start offset of the span.
  • stop – Stop offset of the span.
Raises:

ValueError – if span value is incorrect.

class lookout.style.format.annotations.annotations.Annotation(start:int, stop:int)

Base class for all annotations.

start
stop
span
name
__repr__(self)

Format Annotation object as a string.

__str__(self)

Format Annotation description as a string.

class lookout.style.format.annotations.annotations.LineAnnotation(start:int, stop:int, line:int)

Bases:lookout.style.format.annotations.annotations.Annotation

Line number annotation.

Line numbers are 1-based.

line
class lookout.style.format.annotations.annotations.UASTNodeAnnotation(start:int, stop:int, node:'bblfsh.Node')

Bases:lookout.style.format.annotations.annotations.Annotation

UAST Node annotation.

node
static from_node(node:'bblfsh.Node')

Create the annotation from bblfsh.Node.

class lookout.style.format.annotations.annotations.UASTAnnotation(start:int, stop:int, uast:'bblfsh.Node')

Bases:lookout.style.format.annotations.annotations.UASTNodeAnnotation

Whole file UAST annotation.

uast
parents
class lookout.style.format.annotations.annotations.TokenAnnotation(start:int, stop:int, uast_annotation:Optional[UASTNodeAnnotation]=None)

Bases:lookout.style.format.annotations.annotations.Annotation

Annotation for сode virtual token.

uast_annotation
node

Get the UAST Node belonging to the underlying UASTNodeAnnotation.

Returns:Related bblfsh UAST Node. None if there is no related UASTNodeAnnotation.
has_node

Check if token annotation has related UAST node annotation.

class lookout.style.format.annotations.annotations.AtomicTokenAnnotation

Bases:lookout.style.format.annotations.annotations.TokenAnnotation

Annotation for indivisible tokens generated by FeatureExtractor._classify_vnodes().

to_token_annotation(self)

Convert to TokenAnnotation.

class lookout.style.format.annotations.annotations.RawTokenAnnotation

Bases:lookout.style.format.annotations.annotations.TokenAnnotation

Annotation for raw tokens generated by FeatureExtractor._parse_file().

to_atomic_token_annotation(self)

Convert to AtomicTokenAnnotation.

class lookout.style.format.annotations.annotations.LanguageAnnotation(start:int, stop:int, language:str)

Bases:lookout.style.format.annotations.annotations.Annotation

Language of the file annotation.

language
class lookout.style.format.annotations.annotations.PathAnnotation(start:int, stop:int, path:str)

Bases:lookout.style.format.annotations.annotations.Annotation

File path annotation.

path
class lookout.style.format.annotations.annotations.LabelAnnotation(start:int, stop:int, label:Tuple[int, ...])

Bases:lookout.style.format.annotations.annotations.Annotation

Label annotation that should be predicted by the ML model.

label
class lookout.style.format.annotations.annotations.ClassAnnotation(start:int, stop:int, cls:Tuple[int, ...])

Bases:lookout.style.format.annotations.annotations.Annotation

Class Annotation for atomic format symbols like quote, tab, space, etc.

cls
to_target_annotation(self)

Convert annotation to TargetAnnotation.

class lookout.style.format.annotations.annotations.AccumulatedIndentationAnnotation

Bases:lookout.style.format.annotations.annotations.Annotation

Annotation for “accumulated indentation” token.

class lookout.style.format.annotations.annotations.LinesToCheckAnnotation(start:int, stop:int, lines:FrozenSet[int])

Bases:lookout.style.format.annotations.annotations.Annotation

Annotation to store a set of lines where the style shall be checked.

Lines are 1-based.

lines
class lookout.style.format.annotations.annotations.TokenParentAnnotation(start:int, stop:int, parent:'bblfsh.Node')

Bases:lookout.style.format.annotations.annotations.Annotation

Annotation to store the UAST parent node of a token.

parent