I have a python class with several init variables:
class Foo(object):
def __init__(self, d1, d2):
self.d1 = d1
self.d2 = d2
Partially answering my own question:
Very handy thank you. In version 2020.2 the "Fix all" option is gone. Anyone knows how to add it back?
I haven't found a way to add the missing option back, but a workaround that will accomplish the same, adding all missing fields to the class.
The answer comes from this post: https://stackoverflow.com/a/62060345/1067293
It's a little bit too elaborate, but nonetheless comes in handy when you've more than a few args.
You can start by making a custom Live Template. I'm not sure about whether you can auto-generate variable number of arguments this way, but, for two constructor arguments the live template may look like:
class $class_name$:
def __init__(self, $arg1$, $arg2$):
self.$arg1$ = $arg1$
self.$arg2$ = $arg2$
$END$
This is how I've set it up in PyCharm:
Or, you can change the way you set the instance attributes and generalize it for N arguments, see:
I learned of another way to solve this.