Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language server crashes on some files with annotations #913

Open
FredrikMeyer opened this issue Feb 23, 2021 · 0 comments
Open

Language server crashes on some files with annotations #913

FredrikMeyer opened this issue Feb 23, 2021 · 0 comments

Comments

@FredrikMeyer
Copy link

I'm using this library: https://github.com/awslabs/aws-lambda-powertools-python

And I have functions like this in my main.py file:

@tracer.capture_method
def time_consuming_maybe():
    <something>

However I get this error message in the logs whenever I visit a file containing these annotations:



Traceback (most recent call last):
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pyls_jsonrpc/endpoint.py", line 113, in consume
    self._handle_request(message['id'], message['method'], message.get('params'))
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pyls_jsonrpc/endpoint.py", line 182, in _handle_request
    handler_result = handler(params)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pyls_jsonrpc/dispatchers.py", line 23, in handler
    return method(**(params or {}))
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pyls/python_ls.py", line 334, in m_text_document__document_symbol
    return self.document_symbols(textDocument['uri'])
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pyls/python_ls.py", line 250, in document_symbols
    return flatten(self._hook('pyls_document_symbols', doc_uri))
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pyls/python_ls.py", line 156, in _hook
    return hook_handlers(config=self.config, workspace=workspace, document=doc, **kwargs)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pluggy/manager.py", line 337, in traced_hookexec
    return outcome.get_result()
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pluggy/callers.py", line 52, in from_call
    result = func()
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pluggy/manager.py", line 335, in <lambda>
    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pyls/plugins/symbols.py", line 40, in pyls_document_symbols
    if _include_def(d) and document.path == d.module_path:
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/pyls/plugins/symbols.py", line 83, in _include_def
    definition.type != 'param' and
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/api/classes.py", line 190, in type
    for value in self._name.infer():
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/names.py", line 279, in infer
    return tree_name_to_values(
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/plugins/__init__.py", line 21, in wrapper
    return built_functions[public_name](*args, **kwargs)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/plugins/stdlib.py", line 862, in wrapper
    return func(inference_state, context, tree_name)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/plugins/django.py", line 176, in wrapper
    result = func(inference_state, context, tree_name)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/syntax_tree.py", line 753, in tree_name_to_values
    types = imports.infer_import(context, tree_name)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/cache.py", line 44, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/imports.py", line 59, in infer_import
    values = values.py__getattribute__(
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/base_value.py", line 494, in py__getattribute__
    return ValueSet.from_sets(c.py__getattribute__(*args, **kwargs) for c in self._set)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/base_value.py", line 427, in from_sets
    for set_ in sets:
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/base_value.py", line 494, in <genexpr>
    return ValueSet.from_sets(c.py__getattribute__(*args, **kwargs) for c in self._set)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/base_value.py", line 81, in py__getattribute__
    values = ValueSet.from_sets(name.infer() for name in names)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/base_value.py", line 427, in from_sets
    for set_ in sets:
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/base_value.py", line 81, in <genexpr>
    values = ValueSet.from_sets(name.infer() for name in names)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/names.py", line 279, in infer
    return tree_name_to_values(
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/plugins/__init__.py", line 21, in wrapper
    return built_functions[public_name](*args, **kwargs)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/plugins/stdlib.py", line 862, in wrapper
    return func(inference_state, context, tree_name)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/plugins/django.py", line 176, in wrapper
    result = func(inference_state, context, tree_name)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/syntax_tree.py", line 755, in tree_name_to_values
    types = _apply_decorators(context, node)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/cache.py", line 44, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/syntax_tree.py", line 812, in _apply_decorators
    values = dec_values.execute(arguments.ValuesArguments([values]))
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/base_value.py", line 485, in execute
    return ValueSet.from_sets(c.inference_state.execute(c, arguments) for c in self._set)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/base_value.py", line 427, in from_sets
    for set_ in sets:
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/base_value.py", line 485, in <genexpr>
    return ValueSet.from_sets(c.inference_state.execute(c, arguments) for c in self._set)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/plugins/__init__.py", line 21, in wrapper
    return built_functions[public_name](*args, **kwargs)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/plugins/stdlib.py", line 125, in wrapper
    return call()
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/plugins/stdlib.py", line 107, in call
    return callback(value, arguments=arguments)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/plugins/pytest.py", line 25, in wrapper
    return callback(value, arguments)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/__init__.py", line 119, in execute
    value_set = value.py__call__(arguments=arguments)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/value/function.py", line 118, in py__call__
    return function_execution.infer()
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/value/function.py", line 357, in infer
    if self.is_generator():
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/value/function.py", line 321, in is_generator
    return bool(get_yield_exprs(self.inference_state, self.tree_node))
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/cache.py", line 44, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/Users/fredrikmeyer/code/work/myproject/v-env/lib/python3.9/site-packages/jedi/inference/parser_cache.py", line 6, in get_yield_exprs
    return list(funcdef.iter_yield_exprs())
AttributeError: 'Class' object has no attribute 'iter_yield_exprs'

I've tried updating both my editor plugin (Emacs LSP mode) and my Python language server (0.36.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant