deprecate_submodule

glotaran.deprecation.deprecation_utils.deprecate_submodule(*, deprecated_module_name: str, new_module_name: str, to_be_removed_in_version: str) module[source]

Create a module at runtime which retrieves attributes from new module.

When moving a module, create a variable with the modules name in the parent packages __init__.py, so imports will be redirected to the new module location and a deprecation warning will be given, to help the user adjust the outdated code. Each time an attribute is retrieved there will be a deprecation warning.

Parameters
  • deprecated_module_name (str) – Fully qualified name of the deprecated module e.g.: 'glotaran.analysis.result'

  • new_module_name (str) – Fully qualified name of the new module e.g.: 'glotaran.project.result'

  • to_be_removed_in_version (str) – Version the support for this usage will be removed.

Returns

Module containing

Return type

ModuleType

Examples

When moving the module result from glotaran.analysis.result to glotaran.project.result the following code was added to the old parent packages (glotaran.analysis) __init__.py.

glotaran/analysis/__init__.py
from glotaran.deprecation.deprecation_utils import deprecate_submodule

result = deprecate_submodule(
    deprecated_module_name="glotaran.analysis.result",
    new_module_name="glotaran.project.result",
    to_be_removed_in_version="0.6.0",
)