Issue
IPython tab completion for method parameters is showing more information than I'm expecting to see:
snowch$ ipython3
Python 3.6.2 |Anaconda, Inc.| (default, Sep 21 2017, 18:29:43)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from my_package import MyClass
In [2]: cf = MyClass(<TAB>
abs() api_key=
all() api_key_filename=
any() ArithmeticError >
api_endpoint= ascii()
...
This also happens on instance methods:
In [3]: cf.auth(<TAB>
abs() ascii()
...
Q) Should I be seeing builtin methods like abs()
when I tab complete on my instance methods and constructors?.
My IPCompleter configuration looks like this:
In [4]: %config IPCompleter
IPCompleter options
-----------------
IPCompleter.backslash_combining_completions=<Bool>
Current: True
IPCompleter.debug=<Bool>
Current: False
IPCompleter.greedy=<Bool>
Current: False
IPCompleter.jedi_compute_type_timeout=<Int>
Current: 400
IPCompleter.limit_to__all__=<Bool>
Current: False
IPCompleter.merge_completions=<Bool>
Current: True
IPCompleter.omit__names=<Enum>
Current: 2
IPCompleter.use_jedi=<Bool>
Current: True
Solution
Yes you should, because having function call in methods or constructor is perfectly valid. Actually you can write any expressions in any field when you call a callable.
MyProgressMeter(any(params))
range(abs(value_a - value_b))
obj.frobulate(len(set(items)))
print(len(my_list))
Are reasonable, so on MyProgressMeter(<tab>
, obj.frobulate(<tab>
, print(<tab>
and range(<tab>
you're shown everything that is in local/global namespace that make sense, as well as named parameters.
Instance methods are no different of course.
Note: it is not well known but range
is actually a constructor:
>>> type(range)
<class 'type'>
Answered By - Matt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.