def import_all_modules(
module_name: str, path: typing.Optional[typing.Sequence[str]]=None,
) -> typing.AbstractSet[str]:
"""Import all modules. Maybe it is useful when populate revision script
in alembic with ``--autogenerate`` option. Since alembic can only detect a
change/creation of an object that imported in runtime, importing all
modules helps entity to track in migration script properly.
.. code-block:
>>> from ormeasy.common import import_all_modules
>>> import_all_modules('ormeasy')
:param str module_name: The module name want to import.
:param list[str] or None path: The path to find the root module.
"""
modules = get_all_modules(module_name, path)
for module_name in modules:
importlib.import_module(module_name)
return modules
评论列表
文章目录