In refactoring some code I found a helper method get_records_from_file that has a complex return signature:
class RecordDefinition:
def __init__(self):
self.foo = None
self.bar = None
def get_records_from_file(file_name) -> Dict[int, List[Dict[str, RecordDefinition]]]:
...
After some inspection I understand that this return type really means:
Dict[record_group_id, List[Dict[record_type_id, RecordDefinition]]]
In other projects (and other languages) I've seen this very thing change into:
Dict[record_group_id, List[RecordTypeCollection]]
Which leads to:
Dict[record_group_id, RecordCollection]
And finally ending in:
RecordGroupCollection
Generally, Is this kind of replacement desirable? More explicitly, should I change complex return objects like this to Object Oriented Classes? I see some benefit here that allows structures to be more explicitly named. But this adds a lot of code in the form of smaller classes.
In python, I get the impression that this kind of class creation is frowned upon. Is my assumption correct?