Closed ZanSara closed 1 year ago
This looks great, thank you for this! I had intended that https://github.com/ManderaGeneral/generalimport/blob/ea3e12247fe0512a280b01808966d1996820d94f/generalimport/generalimport_bottom.py#L13 would be used for checking whether generalimport would be used or not, but this is a good use-case I hadn't thought of, it's more intuitive too!
Could you please add unittests for it before I accept it?
Sounds good! I'm going to try. The testing style here is a bit different to what I'm used to, so let me know if I'm on the right track once I push them.
I'm realizing that the overlap with module_is_installed
is large, but it's not 100% the same... for example setuptools
: it might be there, but unless it's imported, is_imported
will return False
.
However I wonder if I would have added is_imported
if I realized there was module_not_installed
already. That makes the API Docs look more important in hindsight :slightly_smiling_face:
I understand what you mean, it could be a little bit ambiguous when is_imported
returns False, but I think it's fine. I think the words "installed" and "imported" have an intuitive difference
I'm going to merge this! Just a heads-up that the CI will fail, I'm getting to that
Congratulations on being my first contributor! It's been 3 years since my first commit to ManderaGeneral, this is a big moment for me 😊
Adds a small function that can be used to check whether a specific package has been mocked by
generalimport
or not without triggering aMissingDependencyException
.I'm personally using this with
sqlalchemy
, where the library needs to generate some base classes at import time. With this function I can decide to generate them only ifsqlalchemy
was actually imported.