You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting a traceback (ending in the line KeyError: '4305da1ea25c27fce08bd14001b76fd54fe42a0724bbd5168c76680a56eda5be') when running flake8 on a simple test script. It appears to have to do with a bad column number passed to jedi in get_inferred_types.
Here's the test script, saved on my machine as test.py:
Save the above script in your current directory under the name test.py
Create a new Python 3.10 venv and activate it
Do a pip install flake8-encodings jedi
Run python -m flake8 test.py
Example session showing the above:
mdickinson@mirzakhani Desktop % python --version
Python 3.10.1
mdickinson@mirzakhani Desktop % python -m venv --clear ~/.venvs/flake8-encodings
mdickinson@mirzakhani Desktop % source ~/.venvs/flake8-encodings/bin/activate
(flake8-encodings) mdickinson@mirzakhani Desktop % pip install flake8-encodings jedi
Collecting flake8-encodings
Using cached flake8_encodings-0.4.0-py3-none-any.whl (25 kB)
Collecting jedi
Using cached jedi-0.18.1-py2.py3-none-any.whl (1.6 MB)
Collecting flake8>=3.7
Using cached flake8-4.0.1-py2.py3-none-any.whl (64 kB)
Collecting astatine>=0.3.1
Using cached astatine-0.3.1-py3-none-any.whl (6.8 kB)
Collecting flake8-helper>=0.1.1
Using cached flake8_helper-0.2.0-py3-none-any.whl (13 kB)
Collecting domdf-python-tools>=2.8.1
Using cached domdf_python_tools-3.1.0-py3-none-any.whl (120 kB)
Collecting parso<0.9.0,>=0.8.0
Using cached parso-0.8.3-py2.py3-none-any.whl (100 kB)
Collecting asttokens>=1.1
Using cached asttokens-2.0.5-py2.py3-none-any.whl (20 kB)
Collecting six
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting typing-extensions>=3.7.4.1
Using cached typing_extensions-4.0.1-py3-none-any.whl (22 kB)
Collecting natsort>=7.0.1
Using cached natsort-8.0.2-py3-none-any.whl (37 kB)
Collecting pycodestyle<2.9.0,>=2.8.0
Using cached pycodestyle-2.8.0-py2.py3-none-any.whl (42 kB)
Collecting pyflakes<2.5.0,>=2.4.0
Using cached pyflakes-2.4.0-py2.py3-none-any.whl (69 kB)
Collecting mccabe<0.7.0,>=0.6.0
Using cached mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Installing collected packages: typing-extensions, six, pyflakes, pycodestyle, natsort, mccabe, flake8, domdf-python-tools, asttokens, parso, flake8-helper, astatine, jedi, flake8-encodings
Successfully installed astatine-0.3.1 asttokens-2.0.5 domdf-python-tools-3.1.0 flake8-4.0.1 flake8-encodings-0.4.0 flake8-helper-0.2.0 jedi-0.18.1 mccabe-0.6.1 natsort-8.0.2 parso-0.8.3 pycodestyle-2.8.0 pyflakes-2.4.0 six-1.16.0 typing-extensions-4.0.1
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
You should consider upgrading via the '/Users/mdickinson/.venvs/flake8-encodings/bin/python -m pip install --upgrade pip' command.
(flake8-encodings) mdickinson@mirzakhani Desktop % python -m flake8 test.py
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8/__main__.py", line 4, in <module>
cli.main()
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8/main/cli.py", line 22, in main
app.run(argv)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8/main/application.py", line 375, in run
self._run(argv)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8/main/application.py", line 364, in _run
self.run_checks()
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8/main/application.py", line 271, in run_checks
self.file_checker_manager.run()
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8/checker.py", line 311, in run
self.run_serial()
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8/checker.py", line 295, in run_serial
checker.run_checks()
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8/checker.py", line 597, in run_checks
self.run_ast_checks()
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8/checker.py", line 500, in run_ast_checks
for (line_number, offset, text, _) in runner:
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8_encodings/__init__.py", line 362, in run
class_visitor.first_visit(self._tree, self.filename)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8_encodings/__init__.py", line 213, in first_visit
self.visit(node)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ast.py", line 410, in visit
return visitor(node)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ast.py", line 418, in generic_visit
self.visit(item)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ast.py", line 410, in visit
return visitor(node)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ast.py", line 420, in generic_visit
self.visit(value)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ast.py", line 410, in visit
return visitor(node)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8_encodings/__init__.py", line 319, in visit_Call
inferred_types = get_inferred_types(self.jedi_script, node)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/flake8_encodings/__init__.py", line 429, in get_inferred_types
for inferred_name in jedi_script.infer(node.lineno, node.func.col_offset):
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/api/helpers.py", line 487, in wrapper
return func(self, line, column, *args, **kwargs)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/api/__init__.py", line 247, in infer
values = helpers.infer(self._inference_state, context, leaf)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/api/helpers.py", line 167, in infer
return inference_state.infer(context, leaf)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/__init__.py", line 180, in infer
return helpers.infer_call_of_leaf(context, name)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/helpers.py", line 79, in infer_call_of_leaf
return context.infer_node(leaf)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/context.py", line 224, in infer_node
return infer_node(self, node)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/syntax_tree.py", line 156, in infer_node
return _infer_node_if_inferred(context, element)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/syntax_tree.py", line 169, in _infer_node_if_inferred
return _infer_node_cached(context, element)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/cache.py", line 44, in wrapper
rv = function(obj, *args, **kwargs)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/syntax_tree.py", line 174, in _infer_node_cached
return _infer_node(context, element)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/debug.py", line 81, in wrapper
return func(*args, **kwargs)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/syntax_tree.py", line 82, in wrapper
return func(context, *args, **kwargs)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/syntax_tree.py", line 184, in _infer_node
return infer_atom(context, element)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/syntax_tree.py", line 304, in infer_atom
return context.py__getattribute__(atom, position=position)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/context.py", line 45, in py__getattribute__
names = self.goto(name_or_str, position)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/context.py", line 34, in goto
names = finder.filter_name(filters, name_or_str)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/finder.py", line 35, in filter_name
for filter in filters:
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/context.py", line 486, in get_global_filters
yield from context.get_filters(
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/context.py", line 318, in get_filters
next(filters, None)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/value/module.py", line 63, in get_filters
ParserTreeFilter(
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/filters.py", line 138, in __init__
super().__init__(parent_context, node_context)
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/inference/filters.py", line 100, in __init__
self._parso_cache_node = get_parso_cache_node(
File "/Users/mdickinson/.venvs/flake8-encodings/lib/python3.10/site-packages/jedi/parser_utils.py", line 287, in get_parso_cache_node
return parser_cache[grammar._hashed][path]
KeyError: '4305da1ea25c27fce08bd14001b76fd54fe42a0724bbd5168c76680a56eda5be'
Without Jedi in the mix, the file validates correctly.
Actual result:
See above for the traceback.
Expected result:
Successful validation (no output to the console, zero exit code)
Reproduces how often:
100% reproducible.
Version
Operating System: macOS 11.6.2
Python: 3.10.1
flake8-encodings: 0.4.0
Also: jedi 0.18.1, flake8 4.0.1
Installation source
PyPI / pip
The text was updated successfully, but these errors were encountered:
Description
I'm getting a traceback (ending in the line
KeyError: '4305da1ea25c27fce08bd14001b76fd54fe42a0724bbd5168c76680a56eda5be'
) when runningflake8
on a simple test script. It appears to have to do with a bad column number passed tojedi
inget_inferred_types
.Here's the test script, saved on my machine as
test.py
:Steps to Reproduce
To reproduce:
test.py
pip install flake8-encodings jedi
python -m flake8 test.py
Example session showing the above:
Without Jedi in the mix, the file validates correctly.
Actual result:
See above for the traceback.
Expected result:
Successful validation (no output to the console, zero exit code)
Reproduces how often:
100% reproducible.
Version
Also: jedi 0.18.1, flake8 4.0.1
Installation source
PyPI / pip
The text was updated successfully, but these errors were encountered: