ipython / ipython/ipython

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

オープン
#14,336 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
tab-completion
主要言語
Python
スター
16.8k
フォーク
4.5k
平均マージ
1日 2時間
マージ済み PR(30日)
6

説明

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`

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。