in src/smepu/argparse.py [0:0]
def reduce_oir(klasses: IR) -> IR:
"""Reduced ObjectIR to just the top-level ones."""
# After lower, we end up with this:
#
# callbacks: {
# '__kind__': 'instance',
# 'class': 'smepu.list',
# 'args': [],
# 'kwargs': {}}
#
# callbacks.0: {
# '__kind__': 'instance',
# 'class': 'dummyest.DummyCallback',
# 'args': [],
# 'kwargs': {'name': 'EarlyStopper'}
# }
#
# callbacks.1: {
# '__kind__': 'instance',
# 'class': 'dummyest.DummyCallback',
# 'args': ['Checkpointer'],
# 'kwargs': {}
# }
#
# So, another step needed to properly assign each ObjectIR as pos- or kw-args of another ObjectIR.
for k, v in klasses.items():
if "." not in k:
# Top-level has no parent.
continue
k2, arg_spec = k.rsplit(".", 1)
object_ir = klasses[k2] # Get the parent ObjectIR
if ObjectIR.is_kwarg(arg_spec):
object_ir.kwargs[arg_spec] = v
else:
object_ir.args_d[arg_spec] = v
return {k: v for k, v in klasses.items() if "." not in k}