0
class Event(object):
    can_i_autocomplete_this = True

class App(object):
    def decorator(self, func):
        self.func = func
    def call():
        self.func(Event())

app = App()

@app.decorator
def hello(something):
   print(something.can_i_autocomplete_this)

app.call()

I use decorator like this. but in this case, something parameter in hello method autocomplete doesn't work in IDE(pycharm). (must support python 2.7)

how can i use autocomplete in this case?

thank you.

kimwz.kr
  • 298
  • 1
  • 9
  • 1
    Possible duplicate of [How to get PyCharm to auto-complete code in methods?](http://stackoverflow.com/questions/5309279/how-to-get-pycharm-to-auto-complete-code-in-methods) – Ian Aug 26 '16 at 11:44

1 Answers1

2

Usages of function are not analyzed in inferring types of parameters.

You could specify type of parameter inside doc:

@app.decorator
def hello(something):
    """
    :param something:
    :type something: Event
    :return:
    """
    print(something.can_i_autocomplete_this)

or using type hinting syntax (since Python 3.5):

@app.decorator
def hello(something: Event):
    print(something.can_i_autocomplete_this)
user2235698
  • 7,053
  • 1
  • 19
  • 27