This repository has been archived by the owner on Oct 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add deprecation warnings on use of deprecated package import
- Loading branch information
Showing
9 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
Useful classes and functionality for building and testing XBlocks | ||
""" | ||
|
||
__version__ = '3.4.1' | ||
__version__ = '4.0.0' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Utilities for warning about the use of deprecated package | ||
See https://github.com/openedx/xblock-utils/issues/197 for details. | ||
""" | ||
|
||
import warnings | ||
|
||
|
||
class DeprecatedPackageWarning(DeprecationWarning): | ||
""" | ||
A warning that a deprecated package is being used. | ||
""" | ||
|
||
def __init__(self, old_import, new_import): | ||
super().__init__() | ||
self.old_import = old_import | ||
self.new_import = new_import | ||
|
||
def __str__(self): | ||
return ( | ||
"Please use import {self.new_import} instead of {self.old_import} as " | ||
"'xblock-utils' package has been deprecated and migrated within 'xblock' package. " | ||
).format(self=self) | ||
|
||
|
||
def warn_deprecated_package(old_import, new_import): | ||
""" | ||
Warn that a package has been deprecated | ||
""" | ||
warnings.warn( | ||
DeprecatedPackageWarning(old_import, new_import), | ||
stacklevel=3, # Should surface the line that is doing the importing. | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters