I am working on a project that has hundreds of dynamically created classes like
CLASSES = [
make_dataclass(...),
make_dataclass(...),
...
]
and I am using this CLASSES list defined in a module so that I can import groups of them instead of each one at a time (also to help out my IDE/static type checker).
Reviewers have said this is not ideal but neither me or them (nor Bing Co-pilot) know what really is the correct solution. Something I have thought of is having a function
def get_classes() -> list:
return [make_dataclass(...), ...]
but does this actually make any difference for the compiler?
I could also have some ClassStore class that has static methods which return the classes, but not sure if there is any difference there other than making the process of importing more clear.
Thanks for any tips you can provide.