sourcery-ai / sourcery

Instant AI code reviews
https://sourcery.ai
MIT License
1.56k stars 71 forks source link

Crash during `sourcery review ./ --fix` #430

Closed tylerlaprade closed 3 months ago

tylerlaprade commented 4 months ago
Traceback (most recent call last):
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/__main__.py", line 671, in <module>
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/click/core.py", line 1157, in __call__
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/click/core.py", line 1078, in main
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/click/core.py", line 1688, in invoke
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/click/core.py", line 1434, in invoke
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/click/core.py", line 783, in invoke
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/__main__.py", line 385, in review
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/binary/command_line_interface/__init__.py", line 394, in review
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/binary/command_line_interface/__init__.py", line 564, in _review
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/hypergraph.py", line 48, in query_text_documents
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/fix.py", line 44, in query_tree
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/skip_comments.py", line 169, in query_tree
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/rule.py", line 160, in query_tree
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/rule.py", line 111, in query_tree
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/rule.py", line 127, in query_node
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/rule.py", line 51, in query_node
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/matchers/replacement.py", line 30, in query_node
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/matchers/pattern.py", line 145, in query_node
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/matchers/pattern.py", line 185, in passes_condition
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/conditions/condition_ast.py", line 55, in evaluate
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/conditions/python/type_conditions.py", line 38, in has_type
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/analysis/python_analysis.py", line 219, in node_type
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/analysis/python_analysis.py", line 205, in node_types
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/analysis/python_analysis.py", line 186, in document_types
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/languages/python_types.py", line 100, in calculate_document_types
  File "/Users/tyler/Code/condor/.env/lib/python3.12/site-packages/sourcery/hypergraph/languages/python_types.py", line 246, in _infer_expression_type
ValueError: too many values to unpack (expected 2)
ruancomelli commented 4 months ago

Hey, @tylerlaprade! Thanks for opening this bug report.

Do you have a code snippet that reproduces this issue?

tylerlaprade commented 4 months ago

I can consistently repro when running it on my entire codebase. I don't know which file is the culprit, though. It still happens now after various other changes in the code from the past couple weeks, including fixing the previously revealed Sourcery errors.

tylerlaprade commented 4 months ago

Not sure if related, two of the autofixes introduce typechecking errors in my code. At least today, those are the last two files successfully checked.

brendanator commented 3 months ago

Hi @tylerlaprade. thanks for reporting this

I've found a fix which will be in the next release