Open
Description
I installed sourcery-analytics
within my virtual environment.
Using python 3.10 withing NixOS (Linux).
When running the command venv/bin/sourcery-analytics analyze [PATH]
the following error occurs
venv/bin/sourcery-analytics analyze vera/rules
Analyzing methods... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/main.py:66 in │
│ cli_analyze │
│ │
│ 63 │ ] │
│ 64 │ │
│ 65 │ if output is OutputChoice.RICH: │
│ ❱ 66 │ │ analyze_rich_output(method_metric, methods, metrics, sort) │
│ 67 │ elif output is OutputChoice.PLAIN: │
│ 68 │ │ analyze_plain_output(methods, metrics, sort) │
│ 69 │ elif output is OutputChoice.CSV: │
│ │
│ ╭───────────────────────────────────────── locals ─────────────────────────────────────────╮ │
│ │ method_metric = [ │ │
│ │ │ <MethodMetricChoice.LENGTH: 'length'>, │ │
│ │ │ <MethodMetricChoice.CYCLOMATIC_COMPLEXITY: 'cyclomatic_complexity'>, │ │
│ │ │ <MethodMetricChoice.COGNITIVE_COMPLEXITY: 'cognitive_complexity'>, │ │
│ │ │ <MethodMetricChoice.WORKING_MEMORY: 'working_memory'> │ │
│ │ ] │ │
│ │ methods = <generator object Extractor._extract_from_directory at 0x7f7a7459ee30> │ │
│ │ metrics = [ │ │
│ │ │ <function method_qualname at 0x7f7a74dfecb0>, │ │
│ │ │ <function method_length at 0x7f7a74dfe950>, │ │
│ │ │ <function method_cyclomatic_complexity at 0x7f7a74dfdc60>, │ │
│ │ │ <function method_cognitive_complexity at 0x7f7a74dfd990>, │ │
│ │ │ <function method_working_memory at 0x7f7a74dff490> │ │
│ │ ] │ │
│ │ output = <OutputChoice.RICH: 'rich'> │ │
│ │ path = PosixPath('vera/rules') │ │
│ │ sort = <MethodMetricChoice.LENGTH: 'length'> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/cli/partials. │
│ py:23 in analyze_rich_output │
│ │
│ 20 │ console = rich.console.Console() │
│ 21 │ methods_progress = rich.progress.track(methods, description="Analyzing methods...") │
│ 22 │ analysis: typing.List[NamedMetricResult] = sorted( │
│ ❱ 23 │ │ analyze(methods_progress, metrics=metrics), │
│ 24 │ │ key=operator.itemgetter(sort.method_method_name), │
│ 25 │ │ reverse=True, │
│ 26 │ ) │
│ │
│ ╭────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ console = <console width=114 ColorSystem.TRUECOLOR> │ │
│ │ method_metric = [ │ │
│ │ │ <MethodMetricChoice.LENGTH: 'length'>, │ │
│ │ │ <MethodMetricChoice.CYCLOMATIC_COMPLEXITY: 'cyclomatic_complexity'>, │ │
│ │ │ <MethodMetricChoice.COGNITIVE_COMPLEXITY: 'cognitive_complexity'>, │ │
│ │ │ <MethodMetricChoice.WORKING_MEMORY: 'working_memory'> │ │
│ │ ] │ │
│ │ methods = <generator object Extractor._extract_from_directory at 0x7f7a7459ee30> │ │
│ │ methods_progress = <generator object track at 0x7f7a7459f290> │ │
│ │ metrics = [ │ │
│ │ │ <function method_qualname at 0x7f7a74dfecb0>, │ │
│ │ │ <function method_length at 0x7f7a74dfe950>, │ │
│ │ │ <function method_cyclomatic_complexity at 0x7f7a74dfdc60>, │ │
│ │ │ <function method_cognitive_complexity at 0x7f7a74dfd990>, │ │
│ │ │ <function method_working_memory at 0x7f7a74dff490> │ │
│ │ ] │ │
│ │ sort = <MethodMetricChoice.LENGTH: 'length'> │ │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/analysis.py:1 │
│ 27 in analyze │
│ │
│ 124 │ metrics = more_itertools.always_iterable(metrics) │
│ 125 │ metric = compounder(*metrics) │
│ 126 │ results = (metric(node) for node in nodes) │
│ ❱ 127 │ return aggregation(results) │
│ 128 │
│ 129 │
│ 130 def assess( │
│ │
│ ╭─────────────────────────────────── locals ────────────────────────────────────╮ │
│ │ aggregation = <class 'list'> │ │
│ │ compounder = <function name_metrics at 0x7f7a74e0c040> │ │
│ │ metric = <function name_metrics.<locals>.name_dict at 0x7f7a745df250> │ │
│ │ metrics = <list_iterator object at 0x7f7a745ed5d0> │ │
│ │ nodes = <generator object track at 0x7f7a7459f290> │ │
│ │ results = <generator object analyze.<locals>.<genexpr> at 0x7f7a7459f300> │ │
│ ╰───────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/analysis.py:1 │
│ 26 in <genexpr> │
│ │
│ 123 │ nodes = more_itertools.always_iterable(nodes, base_type=astroid.nodes.NodeNG) │
│ 124 │ metrics = more_itertools.always_iterable(metrics) │
│ 125 │ metric = compounder(*metrics) │
│ ❱ 126 │ results = (metric(node) for node in nodes) │
│ 127 │ return aggregation(results) │
│ 128 │
│ 129 │
│ │
│ ╭─────────────────────────────── locals ────────────────────────────────╮ │
│ │ .0 = <generator object track at 0x7f7a7459f290> │ │
│ │ metric = <function name_metrics.<locals>.name_dict at 0x7f7a745df250> │ │
│ │ node = <FunctionDef.check_epitech_header l.23 at 0x7f7a745ef6a0> │ │
│ ╰───────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/metrics/compo │
│ unders.py:29 in name_dict │
│ │
│ 26 │ """A compounder which joins the result as a dictionary keyed on the metric names."" │
│ 27 │ │
│ 28 │ def name_dict(node: astroid.nodes.NodeNG) -> "NamedMetricResult": │
│ ❱ 29 │ │ return NamedMetricResult({metric.__name__: metric(node) for metric in metrics}) │
│ 30 │ │
│ 31 │ return name_dict │
│ 32 │
│ │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │ metrics = ( │ │
│ │ │ <function method_qualname at 0x7f7a74dfecb0>, │ │
│ │ │ <function method_length at 0x7f7a74dfe950>, │ │
│ │ │ <function method_cyclomatic_complexity at 0x7f7a74dfdc60>, │ │
│ │ │ <function method_cognitive_complexity at 0x7f7a74dfd990>, │ │
│ │ │ <function method_working_memory at 0x7f7a74dff490> │ │
│ │ ) │ │
│ │ node = <FunctionDef.check_epitech_header l.23 at 0x7f7a745ef6a0> │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/metrics/compo │
│ unders.py:29 in <dictcomp> │
│ │
│ 26 │ """A compounder which joins the result as a dictionary keyed on the metric names."" │
│ 27 │ │
│ 28 │ def name_dict(node: astroid.nodes.NodeNG) -> "NamedMetricResult": │
│ ❱ 29 │ │ return NamedMetricResult({metric.__name__: metric(node) for metric in metrics}) │
│ 30 │ │
│ 31 │ return name_dict │
│ 32 │
│ │
│ ╭────────────────────────────── locals ──────────────────────────────╮ │
│ │ .0 = <tuple_iterator object at 0x7f7a745efe20> │ │
│ │ metric = <function method_length at 0x7f7a74dfe950> │ │
│ │ node = <FunctionDef.check_epitech_header l.23 at 0x7f7a745ef6a0> │ │
│ ╰────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/utils.py:50 │
│ in wrapped │
│ │
│ 47 │ @functools.wraps(node_function) │
│ 48 │ def wrapped(item: NT) -> T: │
│ 49 │ │ if isinstance(item, astroid.nodes.NodeNG): │
│ ❱ 50 │ │ │ return node_function(item) │
│ 51 │ │ if isinstance(item, str): │
│ 52 │ │ │ node = astroid.extract_node(item) │
│ 53 │ │ │ return node_function(node) │
│ │
│ ╭───────────────────────────────── locals ──────────────────────────────────╮ │
│ │ item = <FunctionDef.check_epitech_header l.23 at 0x7f7a745ef6a0> │ │
│ │ manager = <astroid.manager.AstroidManager object at 0x7f7a74df0340> │ │
│ │ node_function = <function method_length at 0x7f7a74dfea70> │ │
│ ╰───────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/utils.py:100 │
│ in wrapped │
│ │
│ 97 │ │ │ │ │ f"for nodes of type {type(node)}. " │
│ 98 │ │ │ │ │ f"Allowed types are: {types}." │
│ 99 │ │ │ │ ) │
│ ❱ 100 │ │ │ return node_function(node) │
│ 101 │ │ │
│ 102 │ │ return wrapped │
│ 103 │
│ │
│ ╭───────────────────────────────── locals ──────────────────────────────────╮ │
│ │ node = <FunctionDef.check_epitech_header l.23 at 0x7f7a745ef6a0> │ │
│ │ node_function = <function method_length at 0x7f7a74dfe9e0> │ │
│ │ types = (<class 'astroid.scoped_nodes.FunctionDef'>,) │ │
│ ╰───────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/metrics/metho │
│ d_length.py:26 in method_length │venv/bin/sourcery-analytics analyze
│ │
│ 23 │ │ >>> method_length("def add(x, y): z = x + y; return z") │
│ 24 │ │ 2 │
│ 25 │ """ │
│ ❱ 26 │ return total_statement_count(method) │
│ 27 │
│ 28 │
│ 29 @nodedispatch │
│ │
│ ╭────────────────────────────── locals ──────────────────────────────╮ │
│ │ method = <FunctionDef.check_epitech_header l.23 at 0x7f7a745ef6a0> │ │
│ ╰────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/utils.py:50 │
│ in wrapped │
│ │
│ 47 │ @functools.wraps(node_function) │
│ 48 │ def wrapped(item: NT) -> T: │
│ 49 │ │ if isinstance(item, astroid.nodes.NodeNG): │
│ ❱ 50 │ │ │ return node_function(item) │
│ 51 │ │ if isinstance(item, str): │
│ 52 │ │ │ node = astroid.extract_node(item) │
│ 53 │ │ │ return node_function(node) │
│ │
│ ╭───────────────────────────────── locals ──────────────────────────────────╮ │
│ │ item = <FunctionDef.check_epitech_header l.23 at 0x7f7a745ef6a0> │ │
│ │ manager = <astroid.manager.AstroidManager object at 0x7f7a74df03d0> │ │
│ │ node_function = <function total_statement_count at 0x7f7a74dfeb00> │ │
│ ╰───────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/metrics/metho │
│ d_length.py:41 in total_statement_count │
│ │
│ 38 │ │ 2 │
│ 39 │ """ │
│ 40 │ visitor = TreeVisitor[int, int](FunctionVisitor(statement_count), collector=sum) │
│ ❱ 41 │ return visitor.visit(node) │
│ 42 │
│ 43 │
│ 44 def statement_count(node: astroid.nodes.NodeNG) -> int: │
│ │
│ ╭─────────────────────────────────── locals ───────────────────────────────────╮ │
│ │ node = <FunctionDef.check_epitech_header l.23 at 0x7f7a745ef6a0> │ │
│ │ visitor = <sourcery_analytics.visitors.TreeVisitor object at 0x7f7a745efe50> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/visitors.py:5 │
│ 3 in visit │
│ │
│ 50 │ def visit(self, node: astroid.nodes.NodeNG) -> P: │
│ 51 │ │ """Enters the node and returns a fact about it.""" │
│ 52 │ │ with self.enter(node): │
│ ❱ 53 │ │ │ return self.touch(node) │
│ 54 │
│ 55 │
│ 56 class IdentityVisitor(Visitor[astroid.nodes.NodeNG]): │
│ │
│ ╭───────────────────────────────── locals ──────────────────────────────────╮ │
│ │ node = <FunctionDef.check_epitech_header l.23 at 0x7f7a745ef6a0> │ │
│ │ self = <sourcery_analytics.visitors.TreeVisitor object at 0x7f7a745efe50> │ │
│ ╰───────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/visitors.py:2 │
│ 01 in touch │
│ │
│ 198 │ │ │ │ yield from self._visit(child) │
│ 199 │ │
│ 200 │ def touch(self, node: astroid.nodes.NodeNG) -> Q: │
│ ❱ 201 │ │ return self.collector(self._visit(node)) │
│ 202 │
│ │
│ ╭───────────────────────────────── locals ──────────────────────────────────╮ │
│ │ node = <FunctionDef.check_epitech_header l.23 at 0x7f7a745ef6a0> │ │
│ │ self = <sourcery_analytics.visitors.TreeVisitor object at 0x7f7a745efe50> │ │
│ ╰───────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/visitors.py:1 │
│ 98 in _visit │
│ │
│ 195 │ │ yield self.sub_visitor.touch(node) │
│ 196 │ │ for child in node.get_children(): │
│ 197 │ │ │ with self.enter(child): │
│ ❱ 198 │ │ │ │ yield from self._visit(child) │
│ 199 │ │
│ 200 │ def touch(self, node: astroid.nodes.NodeNG) -> Q: │
│ 201 │ │ return self.collector(self._visit(node)) │
│ │
│ ╭────────────────────────────────── locals ──────────────────────────────────╮ │
│ │ child = <Arguments l.23 at 0x7f7a745ee530> │ │
│ │ node = <FunctionDef.check_epitech_header l.23 at 0x7f7a745ef6a0> │ │
│ │ self = <sourcery_analytics.visitors.TreeVisitor object at 0x7f7a745efe50> │ │
│ ╰────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/visitors.py:1 │
│ 95 in _visit │
│ │
│ 192 │ │ │ yield │
│ 193 │ │
│ 194 │ def _visit(self, node: astroid.nodes.NodeNG): │
│ ❱ 195 │ │ yield self.sub_visitor.touch(node) │
│ 196 │ │ for child in node.get_children(): │
│ 197 │ │ │ with self.enter(child): │
│ 198 │ │ │ │ yield from self._visit(child) │
│ │
│ ╭───────────────────────────────── locals ──────────────────────────────────╮ │
│ │ node = <Arguments l.23 at 0x7f7a745ee530> │ │
│ │ self = <sourcery_analytics.visitors.TreeVisitor object at 0x7f7a745efe50> │ │
│ ╰───────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/visitors.py:7 │
│ 8 in touch │
│ │
│ 75 │ │ self.function = function │
│ 76 │ │
│ 77 │ def touch(self, node: astroid.nodes.NodeNG) -> P: │
│ ❱ 78 │ │ return self.function(node) │
│ 79 │
│ 80 │
│ 81 class ConditionalVisitor(Visitor[typing.Optional[P]], typing.Generic[P]): │
│ │
│ ╭─────────────────────────────────── locals ────────────────────────────────────╮ │
│ │ node = <Arguments l.23 at 0x7f7a745ee530> │ │
│ │ self = <sourcery_analytics.visitors.FunctionVisitor object at 0x7f7a745efdc0> │ │
│ ╰───────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sigmanificient/dev/bcsc/venv/lib/python3.10/site-packages/sourcery_analytics/metrics/metho │
│ d_length.py:58 in statement_count │
│ │
│ 55 │ │ ), │
│ 56 │ ): │
│ 57 │ │ return 0 │
│ ❱ 58 │ if not isinstance(node, astroid.nodes.Statement): │
│ 59 │ │ return 0 │
│ 60 │ return 1 │
│ 61 │
│ │
│ ╭───────────────── locals ──────────────────╮ │
│ │ node = <Arguments l.23 at 0x7f7a745ee530> │ │
│ ╰───────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: module 'astroid.nodes' has no attribute 'Statement'
Metadata
Assignees
Labels
No labels