ipython / ipython/ipython

Completion of keyword arguments includes arguments from other functions whose names start with the function being completed

Đang mở
#11,322 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
16.8k
Fork
4.5k
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
6

Mô tả

For example:

![screen shot 2018-09-19 at 00 29 42](https://user-images.githubusercontent.com/3627481/45720207-ae1d0180-bba3-11e8-9df7-04a615bee805.png)

Because `bar_more` starts with `bar`, the completer suggests the keyword arguments of `bar_more`, namely `spam`, which is not a valid argument for `bar`.

The relevant code is [here](https://github.com/ipython/ipython/blob/381c2039723a597eda9679d8f072d075e55c8501/IPython/core/completer.py#L1541-L1558). Specifically:

```python
callableMatches = self.global_matches(ids[0])
```

makes `callableMatches == ['bar', 'bar_more']`, and then arguments are fetched from each match:

```python
for callableMatch in callableMatches:
try:
namedArgs = self._default_arguments(eval(callableMatch,
self.namespace))
```

It's as if it's trying to complete the function name at the same time as the argument, but that makes no sense to me and nothing of the sort ever happens. Am I missing something?

Here's a real case using matplotlib:

![screen shot 2018-09-19 at 00 40 53](https://user-images.githubusercontent.com/3627481/45720498-c7727d80-bba4-11e8-8523-288c358c1edb.png)

The signature of [`plot`](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html) is just `(*args, **kwargs)`. The arguments suggested come from [`plot_date`](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot_date.html) and [`plotfile`](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plotfile.html). `plot` will actually accept arbitrary arguments without complaining, but I think it's safe to assume at least some of these suggestions are meaningless.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.