Um, could you fix your first sentence? I'm not sure if I understand what you're trying to say. No offense.
Yes, I admit that. But there's not enough (paid) time to fix everything and there are more important things to fix/change/refactor. It may be a temporary solution or, like a usual makeshift, will last in there forever. I can't tell. It works and that's all that counts for the moment. Maybe in the future in the course of refactoring the project it will be fixed as well. Let me quote one of the greates musicians of our time, Mike Oldfield: only time will tell.
What I was trying to say is that, assuming I understand correctly, the normal way to do something like that would be to use the techniques listed above inside of your __ init __.py file.
Then when they import your module that has some set of undefined plugins, plugin detection and mocking happens there.
I don't know your architecture specifically but my instinct here is that I would never let this out of design because if this were an app, I'm not sure how you inform the user behavior is faked and if is a library, I may be expecting behavior that never happens.
For example, if it was some kind of computational library and it's optional that I have a linear algebra library installed, but I still use that library, my results will be wrong b/c you're going to pretend the function ran. If is a UI, I will apparently think the plugin is installed and be confused b/c it does nothing.
It SEEMS from my perspective that it's more appropriate to let your junior devs code fail b/c it is written wrong then write some code that hides how the infrastructure actually works from them.
1
u/rhytnen Jan 06 '18
I think the normal this use the technique i showed but insde of init the all and to get the behavior you want.
You have to admit changing import is a sign something went wrong.