Defer Django and sqlalchemy imports
Fixes #1070.
Oopsie, I now realize I missed line 5 : from . import alchemy, mogo, mongoengine. Edited my previous comment.
Your suggested change is much less controversial then. :)
I’m wondering if the same change should be applied to the django module?
Yeah, good idea. I didn’t do it at first out of laziness. I just made the change and it wasn’t that hard!
I understand the idea behind this change; however, I would prefer to have an agreement on the overall design (in the issue) before jumping into code.
At a high level, I would be OK with this kind of change if:
- It doesn't require any change on current working code;
- It doesn't scatter
importstatements throughout the codebase; - It breaks cleanly at module import time, not at runtime — i.e as soon as one declares a
DjangoModelFactory/AlchemyModelFactory/ etc, not one they get used.
Would it be possible to adjust this idea to match those? I'd rather avoid increasing the burden on maintenance for the library — including issues opened by users who don't understand why they get import errors when calling their factories…