Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab-completion of callables displays opening paren #58987

Open
wpettersson mannequin opened this issue May 11, 2012 · 6 comments
Open

Tab-completion of callables displays opening paren #58987

wpettersson mannequin opened this issue May 11, 2012 · 6 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@wpettersson
Copy link
Mannequin

wpettersson mannequin commented May 11, 2012

BPO 14782
Nosy @birkenfeld, @facundobatista, @pitrou, @merwok, @bitdancer, @vadmium

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2012-05-11.12:16:25.859>
labels = ['type-bug', 'library']
title = 'Tab-completion of callables displays opening paren'
updated_at = <Date 2016-05-13.12:51:25.843>
user = 'https://bugs.python.org/wpettersson'

bugs.python.org fields:

activity = <Date 2016-05-13.12:51:25.843>
actor = 'martin.panter'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2012-05-11.12:16:25.859>
creator = 'wpettersson'
dependencies = []
files = []
hgrepos = []
issue_num = 14782
keywords = []
message_count = 4.0
messages = ['160412', '160420', '160633', '265472']
nosy_count = 10.0
nosy_names = ['georg.brandl', 'facundobatista', 'rnd0110', 'pitrou', 'gpolo', 'eric.araujo', 'dieresys', 'r.david.murray', 'martin.panter', 'wpettersson']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue14782'
versions = []

@wpettersson
Copy link
Mannequin Author

wpettersson mannequin commented May 11, 2012

With tab completion enabled via rlcompleter and readline, tab-completion will assume anything that is callable (by callable(val)) is going to be called. For example, the below code defines a class "CCC" that is callable and has a static function. However, typing 
>>> CC
and then pressing tab results in the following.
>>> CCC(
Note the extra parentheses. It would be nice if these weren't added if the object also has some other reasonable choices.

However, I don't know what would be "reasonable" here. Somehow we'd have to detect whether a callable class has static methods, possibly via dir() or directly checking class.__dict__ but at this point I am not comfortable enough with python to suggest decent solutions.

>>> class CCC:                                                                       
...   def __call__(self):
...     print "call"
...   @staticmethod
...   def f(a):
...     print "Static",a
... 
>>>CC<TAB>
>>>CCC(

@wpettersson wpettersson mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels May 11, 2012
@merwok
Copy link
Member

merwok commented May 11, 2012

This annoys me too, for all callable objects actually (e.g. I type "help(someprefix" then Tab then I have to delete the "(" before typing ")" and Enter), but I think it was a deliberate change. I may have the original bug report open in a browser tab at home, I’ll check.

@merwok merwok changed the title Tabcompletion of classes with static methods and __call__ has extra bracket Tab-completion of classes displays opening paren May 11, 2012
@merwok merwok changed the title Tab-completion of classes displays opening paren Tab-completion of callables displays opening paren May 11, 2012
@bitdancer
Copy link
Member

It's bpo-449227.

@vadmium
Copy link
Member

vadmium commented May 13, 2016

FWIW, count me against the automatic brackets as well. Another way it gets in the road:

>> class C(object(. . .

In bpo-5062, Carl thought there might be a switch to turn the behaviour off. Perhaps we could add some sort of configuration option.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@iritkatriel
Copy link
Member

iritkatriel commented Oct 28, 2023

It changed by now to complete with "()" rather than just "(".

bd4a3f2

@merwok
Copy link
Member

merwok commented Oct 29, 2023

That makes two characters to delete for people annoyed by the behaviour 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants