1

Is there any way to allow for keyword parameter suggestions when using **kwargs style function inputs? The closest thing I could think of would be type suggestions in a format such as:

class Classy(object):
    var1    = str()
    var2    = list()
    var3    = list()

def myfunc(param1, **kwargs: **Classy):
    # actions
    # ...

The purpose or use case of this being IDE code hinting -- expand Jedi's functionality for instance. Is there already any sort of functionality like this in existence?

ehiller
  • 1,346
  • 17
  • 32

1 Answers1

0

PEP-484 on arbitrary argument lists and default argument values states that:

Arbitrary argument lists can as well be type annotated, so that the definition:

def foo(*args: str, **kwds: int): ...

is acceptable and it means that, e.g., all of the following represent function calls with valid types of arguments:

foo('a', 'b', 'c')
foo(x=1, y=2)
foo('', z=0)

More formally it means that you specify the type of one such argument. So if you want all values of the kwargs to be Classy objects, you specify it with : Classy. Like:

def myfunc(param1, **kwargs: Classy):
    # actions
    pass

This is the adviced way to do it. That of course does not mean an IDE supports this. But if the IDE follows the guidelines, that should be the way to specify it.

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
  • But it is not possible to have the IDE aware of the potential properties of the object, such as `var1`, `var2`, `var3` ? – ehiller Sep 23 '17 at 00:05