ipython / ipython/ipython

Feature Request : Autocomplete and docstring working when instantiating using class directly

Open
#14,336 3 comments 0 reactions 0 assignees View on GitHub
tab-completion
Dominant language
Python
Stars
16.8k
Forks
4.5k
Avg merge
1d 2h
Merged PRs (30d)
6

Description

Refer to the reproducer and gif below.

```
class Foo:

def __init__(self):
self.name = "My name"

def get_name(self):
'''
This is a sample doctring
'''
print(self.name)
```
![Animation](https://github.com/ipython/ipython/assets/56246494/51b0823d-5ea4-4226-8bc7-0f73f9e3e558)

As shown, both autocomplete and docstring features are working when we instantiate an object first. However, they stop working correctly when we instantiate using class directly.

Some further points :-

- In tab-completion, the intention is not to execute code so it makes sense that `Foo().` doesn't work. But in doing `Foo().get_name??`, we are executing that cell, and hence, expecting the resulting docstring.
- Alternatively, is it possible to statically determine what `Foo()` returns? In that case, we can use that result to fix both issues.
- The autocomplete issue does fix itself when `%config IPCompleter.use_jedi` is set to `True`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.