Skip to content

Commit

Permalink
Fix: Fix various lint errors. Issue #14
Browse files Browse the repository at this point in the history
  • Loading branch information
iZafiro committed Feb 25, 2020
1 parent 29f9ee8 commit 5fab721
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions wemake_python_styleguide/visitors/ast/complexity/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
_FunctionCounter,
]


@final
class _ComplexityExitMetrics(object):
"""Helper class to store counters of statements that exit from a function."""
"""Helper class to store counters of statements that
exit from a function."""

def __init__(self) -> None:
self.returns: _FunctionCounter = defaultdict(int)
Expand All @@ -64,7 +66,7 @@ def __init__(self) -> None:
self.variables: DefaultDict[AnyFunctionDef, List[str]] = defaultdict(
list,
)
self._exit_metrics = _ComplexityExitMetrics()
self.exit_metrics = _ComplexityExitMetrics()

def check_arguments_count(self, node: AnyFunctionDefAndLambda) -> None:
"""Checks the number of the arguments in a function."""
Expand Down Expand Up @@ -111,11 +113,11 @@ def _check_sub_node(
self._update_variables(node, sub_node)

error_counters: _NodeTypeHandler = {
ast.Return: self._exit_metrics.returns,
ast.Return: self.exit_metrics.returns,
ast.Expr: self.expressions,
ast.Await: self.awaits,
ast.Assert: self.asserts,
ast.Raise: self._exit_metrics.raises,
ast.Raise: self.exit_metrics.raises,
}

for types, counter in error_counters.items():
Expand Down Expand Up @@ -211,7 +213,7 @@ def _function_checks(self) -> List[_CheckRule]:
TooManyArgumentsViolation,
),
(
self._counter._exit_metrics.returns,
self._counter.exit_metrics.returns,
self.options.max_returns,
TooManyReturnsViolation,
),
Expand All @@ -226,7 +228,7 @@ def _function_checks(self) -> List[_CheckRule]:
TooManyAssertsViolation,
),
(
self._counter._exit_metrics.raises,
self._counter.exit_metrics.raises,
self.options.max_raises,
TooManyRaisesViolation,
),
Expand Down

0 comments on commit 5fab721

Please sign in to comment.