rope
rope copied to clipboard
GenerateClass should generate `__init__` with constructor arguments
Is your feature request related to a problem? Please describe.
Given that FooBar is an undefined class, and you have a code that looks like this:
result = FooBar(
arg='abc'
)
Currently, Rope will generate a new class structure that looks like this:
class FooBar(object):
pass
result = FooBar(
arg='abc'
)
Describe the solution you'd like
Rope should generate the __init__ template and set arguments to self:
class FooBar(object):
def __init__(self, arg='abc'):
self.arg = arg
result = FooBar(
arg='abc'
)
Additional Context
- This feature is currently implemented in
rope/contrib/generate.py::GenerateClass - Some code from GenerateFunction may be reusable here