From 929fe06127e6960b17327bdffbfaf061e767b93f Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 29 Jun 2022 14:13:25 +0200 Subject: [PATCH] added deprecation warning to anatomy lib --- openpype/lib/anatomy.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/openpype/lib/anatomy.py b/openpype/lib/anatomy.py index b62b207ade..6d339f058f 100644 --- a/openpype/lib/anatomy.py +++ b/openpype/lib/anatomy.py @@ -1,3 +1,38 @@ +"""Code related to project Anatomy was moved +to 'openpype.pipeline.anatomy' please change your imports as soon as +possible. File will be probably removed in OpenPype 3.14.* +""" + +import warnings +import functools + + +class AnatomyDeprecatedWarning(DeprecationWarning): + pass + + +def anatomy_deprecated(func): + """Mark functions as deprecated. + + It will result in a warning being emitted when the function is used. + """ + + @functools.wraps(func) + def new_func(*args, **kwargs): + warnings.simplefilter("always", AnatomyDeprecatedWarning) + warnings.warn( + ( + "Deprecated import of 'Anatomy'." + " Class was moved to 'openpype.pipeline.anatomy'." + " Please change your imports of Anatomy in codebase." + ), + category=AnatomyDeprecatedWarning + ) + return func(*args, **kwargs) + return new_func + + +@anatomy_deprecated def Anatomy(*args, **kwargs): - from openpype.pipeline import Anatomy + from openpype.pipeline.anatomy import Anatomy return Anatomy(*args, **kwargs)