Skip to content

Do not swallow StatisticsError #21

@Masynchin

Description

@Masynchin

This AverageIndent swallows exception when its lines empty:

ndnt/ndnt/indent.py

Lines 28 to 41 in 091c121

class AverageIndent:
"""Average indent of lines block."""
def __init__(self, origin: Lines):
self.origin = origin
def value(self) -> float:
"""Average indent itself."""
indents = map(Indent, self.origin)
try:
return mean(indent.length() for indent in indents)
except StatisticsError:
# if origin has no lines
return 0.0

This is why we can't either filter out empty indents or do zero by ourselves.

Goals:

  • Move exception handling to another class

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions