guilatrova / tryceratops

A linter to prevent exception handling antipatterns in Python (limited only for those who like dinosaurs).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using experimental mode yields AttributeError

MaxG87 opened this issue · comments

First, thank you for the effort to establish another linter. I am looking forward to adopting it to my projects.

I ran tryceratops --experimental . against one of my projects ButterBackup. Tryceratops encountered some AttributeError which it logged nicely.

I run version 0.2.3, installed via pipx.

I just wanted to bring this to your attention.

2021-07-14 08:32:16:tryceratops.analyzers.main:11644:79 ERROR Exception raised when running <class 'tryceratops.analyzers.call.CallAvoidCheckingToContinueAnalyzer'> on ./src/butter_backup/device_managers.py
Traceback (most recent call last):
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/main.py", line 71, in analyze
    found_violations = analyzer.check(tree, filename)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 126, in check
    self._scan_deeper(node, False)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 118, in _scan_deeper
    self._scan_deeper(child, may_contain_violations)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 118, in _scan_deeper
    self._scan_deeper(child, may_contain_violations)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 107, in _scan_deeper
    self._scan_assignments(node)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 65, in _scan_assignments
    assignments = {raw.targets[0].id: raw for raw in raw_assignments}
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 65, in <dictcomp>
    assignments = {raw.targets[0].id: raw for raw in raw_assignments}
AttributeError: 'Attribute' object has no attribute 'id'
2021-07-14 08:32:16:tryceratops.analyzers.main:11644:79 ERROR Exception raised when running <class 'tryceratops.analyzers.call.CallAvoidCheckingToContinueAnalyzer'> on ./tests/test_mounted_device.py
Traceback (most recent call last):
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/main.py", line 71, in analyze
    found_violations = analyzer.check(tree, filename)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 126, in check
    self._scan_deeper(node, False)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 118, in _scan_deeper
    self._scan_deeper(child, may_contain_violations)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 107, in _scan_deeper
    self._scan_assignments(node)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 63, in _scan_assignments
    raw_assignments = [stm for stm in node.body if is_assigned_from_call(stm)]
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 63, in <listcomp>
    raw_assignments = [stm for stm in node.body if is_assigned_from_call(stm)]
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 60, in is_assigned_from_call
    self.assignments_from_calls.pop(node.targets[0].id, None)
AttributeError: 'Tuple' object has no attribute 'id'
2021-07-14 08:32:16:tryceratops.analyzers.main:11644:79 ERROR Exception raised when running <class 'tryceratops.analyzers.call.CallAvoidCheckingToContinueAnalyzer'> on ./tests/test_config_parser.py
Traceback (most recent call last):
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/main.py", line 71, in analyze
    found_violations = analyzer.check(tree, filename)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 126, in check
    self._scan_deeper(node, False)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 118, in _scan_deeper
    self._scan_deeper(child, may_contain_violations)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 107, in _scan_deeper
    self._scan_assignments(node)
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 63, in _scan_assignments
    raw_assignments = [stm for stm in node.body if is_assigned_from_call(stm)]
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 63, in <listcomp>
    raw_assignments = [stm for stm in node.body if is_assigned_from_call(stm)]
  File "/home/user/.local/pipx/venvs/tryceratops/lib/python3.9/site-packages/tryceratops/analyzers/call.py", line 60, in is_assigned_from_call
    self.assignments_from_calls.pop(node.targets[0].id, None)
AttributeError: 'Subscript' object has no attribute 'id'

Thank you very much for reporting, I'll take a look over the weekend!
I'm so glad to hear you're looking forward to including it in your project. Let me know if you do. I'll keep this issue open until I fix it.

I just solved it and I'm about to release it. Please, keep testing it and let me know how it goes!!

Thank you for your support! 🤗