python / cpython

The Python programming language
https://www.python.org
Other
62.35k stars 29.94k forks source link

Display CallTips for classes using metaclasses. #45318

Closed 9caaddf3-c697-4279-8dbe-41f8547cedf8 closed 16 years ago

9caaddf3-c697-4279-8dbe-41f8547cedf8 commented 17 years ago
BPO 1775388
Nosy @kbkaiser

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: ```python assignee = 'https://github.com/kbkaiser' closed_at = created_at = labels = ['expert-IDLE'] title = 'Display CallTips for classes using metaclasses.' updated_at = user = 'https://bugs.python.org/noamr' ``` bugs.python.org fields: ```python activity = actor = 'kbk' assignee = 'kbk' closed = True closed_date = closer = 'kbk' components = ['IDLE'] creation = creator = 'noamr' dependencies = [] files = [] hgrepos = [] issue_num = 1775388 keywords = [] message_count = 2.0 messages = ['32646', '56298'] nosy_count = 2.0 nosy_names = ['kbk', 'noamr'] pr_nums = [] priority = 'normal' resolution = 'out of date' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue1775388' versions = [] ```

9caaddf3-c697-4279-8dbe-41f8547cedf8 commented 17 years ago

Hello,

Currently, if you write something like this:

class MyType(type):
    pass

class MyClass(object):
    __metaclass__ = MyType
    def __init__(self, a):
        pass

And write in the shell:

>> MyClass(

a calltip won't be displayed.

To fix this, replace this line in CallTups.py:

if type(ob) in (types.ClassType, types.TypeType):

with this one:

if issubclass(type(ob), (types.ClassType, types.TypeType)):

and now it works.

Thanks, Noam

kbkaiser commented 16 years ago

Appears this was fixed at r55818, though with a typo. Module heavily rewritten since then to use the inspect module. The example below now works without further changes.