match4everyone / match4healthcare

Helping hospitals find qualified medicine students (Hackathon #wirvsvirus). A more flexibel version is currently in development under match4everyone/match4everything,
https://match4healthcare.de
Other
17 stars 10 forks source link

Import all submodules into module #525

Open kevihiiin opened 4 years ago

kevihiiin commented 4 years ago

The idea is to import all submodules for a module inside the __init__.py file for cleaner access to classes and functions. The module would behave like a big file with all its subclasses.

The proposal @feeds wrote loads all the submodules dynamically on startup. However some (probably all) IDEs fail to detect the dynamically loaded modules resulting in the linter to giving false errors of non-existing modules.


Let's test this with more people of our team whether this works with IDE linting or whether we need special configuration for this to work, which should then maybe be included in the repository.

Originally posted by @bjrne in https://github.com/match4everyone/match4healthcare/pull/509

kevihiiin commented 4 years ago

Some ideas:

The python stub can probably be automatically generated with a pre-commit hook? Not sure if methods can be found if they are missing in the python stub.

Both methods would involve manually adding the files needed to be imported. Leaving it out would only result in the IDE to cry, the code would still work (because of the automatic dynamic import on startup)


Static hack described here: https://github.com/tensorpack/tensorpack/issues/656 https://github.com/celery/kombu/blob/master/kombu/__init__.py#L24-L35