Menu

#180 Some way to provide type hints to the pydev analyzer

open
nobody
None
5
2006-10-23
2006-10-23
No

In order to make intellisense a little bit more useful,
it would be great to be able to annotate the code in
various ways so as to provide type hints to the pydev
analyzer. For example, there could be a comment or
some other annotation on methods that could indicate
the type that will be returned. That way, intellisense
could work even if the variable is the result of a
method call.

Discussion

  • Alve

    Alve - 2007-03-27

    Logged In: YES
    user_id=1529456
    Originator: NO

    Yes, I Agree. That would be a very good thing.

     
  • Nobody/Anonymous

    Logged In: NO

    I got good results with constructions like:
    if False:
    my_obj = SuperCoolClass()

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2007-06-11

    Logged In: YES
    user_id=617340
    Originator: NO

    Probably it should at least take into account:
    assert isinstance(obj, MyClass)

     
  • Kirby Zhou

    Kirby Zhou - 2007-06-27

    Logged In: YES
    user_id=536423
    Originator: NO

    the tag @type/@rtype from epydoc seems not work

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2007-09-09

    Logged In: YES
    user_id=617340
    Originator: NO

    This support was added in 1.3.7 (but docstring analysis for @type/@rtype is not there):

    The folowing cases are now considered in code-completion to discover the type of a variable:

    * Type/Interface checking: (note that 'assert' is required) assert isinstance(obj, Interface) -- default from python
    * assert Interface.implementedBy(obj) -- zope
    * assert IsImplementation(obj, Interface) -- custom request
    * assert IsInterfaceDeclared(obj, Interface) -- custom request

    * Factory methods a = adapt(obj, Interface) -- pyprotocols
    * a = obj.GetAdapter(Interface) -- custom request
    * a = obj.get_adapter(Interface) -- custom request
    * a = GetSingleton(Interface) -- custom request
    * a = GetImplementation(Interface) -- custom request

     
  • Nobody/Anonymous

    Logged In: NO

    assert isinstance(obj, Interface) works like a charm for me.
    But still it would be great if @type and @rtype could be supported in future versions.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.