relocated_module

(function from pyomo.common.deprecation)

pyomo.common.deprecation.relocated_module(new_name, msg=None, logger=None, version=None, remove_in=None)[source]

DEPRECATED.

Provide a deprecation path for moved / renamed modules

Upon import, the old module (that called relocated_module()) will be replaced in sys.modules by an alias that points directly to the new module. As a result, the old module should have only two lines of executable Python code (the import of relocated_module and the call to it).

Note

This method (which was placed in the old module that is being removed) is deprecated and should be replaced by calls to moved_module(), which can be called in any parent scope of the removed module and does not require that the old module continue to exist in the project.

Parameters:
  • new_name (str) – The new (fully-qualified) module name

  • msg (str) – A custom deprecation message.

  • logger (str) – The logger to use for emitting the warning (default: the calling pyomo package, or “pyomo”)

  • version (str [required]) – The version in which the module was renamed or moved. General practice is to set version to the current development version (from pyomo –version) during development and update it to the actual release as part of the release process.

  • remove_in (str) – The version in which the module will be removed from the code.

Example

>>> from pyomo.common.deprecation import relocated_module
>>> relocated_module('pyomo.common.deprecation', version='1.2.3')
WARNING: DEPRECATED: ... The '...' module has been moved to
    'pyomo.common.deprecation'. Please update your import.
    (deprecated in 1.2.3) ...

Deprecated since version 6.8.1: relocated_module() has been deprecated. Please use moved_module()