WhiteMemory99 / Intellij-Python-Inlay-Params

A PyCharm plugin that implements inlay parameter and type annotation hints for Python.
https://plugins.jetbrains.com/plugin/19538
MIT License
36 stars 5 forks source link

Support single argument hints #36

Closed baterflyrity closed 9 months ago

baterflyrity commented 1 year ago

Hi!

Can please hint for single argument be added? As for now only 2+ arguments are hinted.

WhiteMemory99 commented 1 year ago

Hi. Why would you need a hint for a single argument? As I see it, their primary purpose is to improve readability when you manage several arguments. When you have a single argument, the function name itself should serve as a hint.

Still, I will probably add a settings option for that in the next update.

baterflyrity commented 1 year ago

Thanks a lot, it would be grateful.

Why would you need a hint for a single argument?

Because sometimes single argument is not the only one.

def decrease(step=1, start=2):
    return start - step

decrease(3) # 3-- → -1 [wrong]
decrease(start=3) # 3-- → 2 [ok]

As you can see the function decrease call is non-obvious here. Ofcourse, this signature is pretty ugly but some signatures can not be changed from user code.

divaltor commented 9 months ago

We would think about adding support for such rare cases without breaking the old behavior

WhiteMemory99 commented 9 months ago

Thanks a lot, it would be grateful.

Why would you need a hint for a single argument?

Because sometimes single argument is not the only one.

def decrease(step=1, start=2):
    return start - step

decrease(3) # 3-- → -1 [wrong]
decrease(start=3) # 3-- → 2 [ok]

As you can see the function decrease call is non-obvious here. Ofcourse, this signature is pretty ugly but some signatures can not be changed from user code.

The sample provided by you would actually show the parameter hint, since there are 2 parameters defined in the function. The hints only omitted if:

Even so, I will add an option to the settings to show them even with a single parameter case, just to suit everyone's needs.