sloria / konch

Configures your Python shell.
https://konch.readthedocs.io/
MIT License
406 stars 18 forks source link

'NoneType' object has no attribute 'type' when using Konch and Pandas? #210

Open Peder2911 opened 3 years ago

Peder2911 commented 3 years ago

I am encountering a breaking bug that causes Konch to crash. I am using Konch inside a venv using pipx, with Pandas, doing some data analysis. Random commands raise the following exception (last command was dataframe["col"].values):

~/.local/pipx/venvs/konch/lib/python3.8/site-packages/ptpython/completer.py in get_completions(self, document, complete_event)
    258             else:
    259                 # Move function parameters to the top.
--> 260                 jedi_completions = sorted(
    261                     jedi_completions,
    262                     key=lambda jc: (

~/.local/pipx/venvs/konch/lib/python3.8/site-packages/ptpython/completer.py in <lambda>(jc)
    262                     key=lambda jc: (
    263                         # Params first.
--> 264                         jc.type != "param",
    265                         # Private at the end.
    266                         jc.name.startswith("_"),

~/.local/pipx/venvs/konch/lib/python3.8/site-packages/jedi/api/classes.py in type(self)
    717             )
    718
--> 719         return super().type
    720
    721     def get_completion_prefix_length(self):

~/.local/pipx/venvs/konch/lib/python3.8/site-packages/jedi/api/classes.py in type(self)
    187             for value in self._name.infer():
    188                 return value.api_type
--> 189         return self._name.api_type
    190
    191     @property

~/.local/pipx/venvs/konch/lib/python3.8/site-packages/jedi/inference/names.py in __getattr__(self, name)
    618
    619     def __getattr__(self, name):
--> 620         return getattr(self._wrapped_name, name)
    621
    622     def __repr__(self):

~/.local/pipx/venvs/konch/lib/python3.8/site-packages/jedi/inference/value/klass.py in api_type(self)
     78         if self.tree_name is not None:
     79             definition = self.tree_name.get_definition()
---> 80             if definition.type == 'funcdef':
     81                 if function_is_property(definition):
     82                     # This essentially checks if there is an @property before

AttributeError: 'NoneType' object has no attribute 'type'
Peder2911 commented 3 years ago

Heres' a reprex:

import pandas as pd
import numpy as np
data = pd.DataFrame(np.zeros((10,10)),columns=list(string.ascii_letters[:10]))
data["a"].values

This raises the above error.

Peder2911 commented 3 years ago

Using konch 4.3.0