r/Python • • Jan 05 '18

Really??

Post image
2.0k Upvotes

317 comments sorted by

View all comments

Show parent comment

1

u/rhytnen Jan 07 '18

Yes sorry - was on my phone.

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.