Open bradakstx opened 2 years ago
Yes, the way __getitem__
is implemented requires subclasses to accept an empty constructor. You can override __getitem__
to do the right thing and pass the right arguments as well.
Alternatively you could implement an instance method on Structure
like _instantiate_empty_structure
that takes no arguments and has a default implementation returning type(self)()
that you override in your subclass. That would be a minimally invasive fix that would allow you to override that limitation in your subclass.
I tried inheriting from
AmberParm
while adding some arguments and adding required positional arguments to the constructor. This works just fine with usingsuper().__init__
, etc. However, when generating a new object using brackets, this leads to a signature error insideStructure.__getitem__()
. Here's a MWE using the example files:The relevant traceback parts are:
I think this is a fixable issue(?) or else maybe it's a feature and the correct way to do this is with a default arguments or maybe a classmethod? I guess the problem is that
__getitem__
requires the possibility of a blank constructor? At the very least we can probably improve the error message as to what is truly wrong.