Eclipse pydev autocompletion on metaclasses

2009-12-17
2013-03-15
  • Zachary Walker

    Zachary Walker - 2009-12-17

    Does pydev support autocompletion on metaclasses?

    Sepcifically I am working with python protocol buffer modules.
    Using Ipython I am able to import a protocol buffer module and see memebers of the message metaclasses via auto completion, specifically the declared enums for a message if you are familiar with protcol buffers.  Using pydev, I can not get the same auto completion to work.

    Is this not supported by pydev or am I missing something.

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2009-12-18

    If it's a module you can use as a forced builtin then it should be supported, but the static analyzer is not able to get it. See: 

    Cheers,

    Fabio

      : http://pydev.org/manual_101_interpreter.html

     
  • Zachary Walker

    Zachary Walker - 2009-12-18

    Fabio,

    Thanks for your response.  Yes it is a module and I tried following the linked instructions with no joy.  I added both the test.py module and the base google package that test.py imports to the builtins and made sure they were on the python path.  Below I am posting a simplified example of the module I would like to have auto completion for.  If I understand how the builtins work it seems like the example below should work like it does in ipython.
    #example
    <pre>
    import test
    t = test.Test
    t.  <== I would like to see "test_field" as an auto completion option here
    </pre>

    #test.py
    <pre>
    from google.protobuf import descriptor
    from google.protobuf import message
    from google.protobuf import reflection
    from google.protobuf import service
    from google.protobuf import service_reflection
    from google.protobuf import descriptor_pb2

    _TEST = descriptor.Descriptor(
      name='Test',
      full_name='Test',
      filename='test.proto',
      containing_type=None,
      fields=[
        descriptor.FieldDescriptor(
          name='test_field', full_name='Test.field', index=0,
          number=1, type=9, cpp_type=9, label=1,
          default_value=unicode("", "utf-8"),
          message_type=None, enum_type=None, containing_type=None,
          is_extension=False, extension_scope=None,
          options=None),
      ],
      extensions=[
      ],
      nested_types=,  # TODO(robinson): Implement.
      enum_types=[
      ],
      options=None)

    class Test(message.Message):
      __metaclass__ = reflection.GeneratedProtocolMessageType
      DESCRIPTOR = _TEST
    </pre>

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2009-12-19

    It could be that the info wasn't refreshed (in a pydev editor, you can try to kill the shells: "Ctrl + 2 + kill" and see if that works).

    If it doesn't work, can you create a bug-report with that test and also giving info on the pythonpath you have set (and where those files are)?

    Cheers,

    Fabio

     
  • Anonymous - 2011-02-24

    Allow me to resurrect this topic…

    Is it possible for PyDev to support metaclass autocompletion in the case below:

    class Meta(type):
        field = ['myfield', 'another']
    class Base(object):
        __metaclass__ = Meta
    class O(Base):
        pass
    O().fields 
    # PyDev can know that fields exists (and not issue a waring about it) and autocomplete it as a list
    # It just have to look the inheritance chain for __metaclass__.
    

    Regards,
    Emil

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-02-24

    Not in the static analyzer (please open a feature request for that).

    Cheers,

    Fabio