From 3b93d1428c2b0c7e0211af1f53391ab952ebf1b5 Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Fri, 17 Jun 2022 07:41:44 -0400 Subject: [PATCH] feat: warn when old safe_lxml import path is used (#30554) See docstring of `./safe_lxml/__init__.py` for details. --- safe_lxml/__init__.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/safe_lxml/__init__.py b/safe_lxml/__init__.py index dbbc0ed499..e07cbde02d 100644 --- a/safe_lxml/__init__.py +++ b/safe_lxml/__init__.py @@ -1,5 +1,5 @@ """ -Temporary import path shim module. +Temporary import path shim module for openedx.core.lib.safe_lxml. Previously, the safe_lxml package was housed in common/lib/safe_lxml. It was installed as its own Python project, so instead of its import path @@ -11,17 +11,26 @@ it was instead just: import safe_lxml -To increase the sanity of edx-platform and simplify its tooling, we are -moving the safe_lxml package to openedx/core/lib (in tihs same repo) and +To increase the sanity of edx-platform and simplify its tooling, we have +moved the safe_lxml package to openedx/core/lib (in tihs same repo) and changing its import path to: import openedx.core.lib.safe_lxml -In order to maintain backwards-compatibility with code using the -old import path for one release, we expose this compatibility module. +For details, see: +https://openedx.atlassian.net/browse/BOM-2583 (public, but requires account) -Jira ticket (public, but requires account): https://openedx.atlassian.net/browse/BOM-2583 -Target removal for this shim module: by Olive. +In order to maintain backwards-compatibility with code using the +old import path for one release, we expose this temporary compatibility +module and raise a warning when the old import path is used. +This entire `safe_lxml` shim folder can be removed after 2023-01-01. +In the Poplar release, 'import safe_lxml' will stop working entirely. """ +import warnings + +warnings.warn( + "Importing from 'safe_lxml' instead of 'openedx.core.lib.safe_lxml' is deprecated.", + stacklevel=3, # Should surface the line that is doing the importing. +) from openedx.core.lib.safe_lxml import * # pylint: disable=unused-wildcard-import,wrong-import-order