-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add and use VersionedDeprecationWarning (#944)
* Add and use VersionedDeprecationWarning * Use remove_version instead. * Fix merge * Apply suggestions from code review Co-authored-by: Daniel King <[email protected]> --------- Co-authored-by: Daniel King <[email protected]>
- Loading branch information
Showing
7 changed files
with
73 additions
and
26 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 |
---|---|---|
|
@@ -95,4 +95,4 @@ | |
'TiktokenTokenizerWrapper', | ||
] | ||
|
||
__version__ = '0.4.0' | ||
__version__ = '0.5.0' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2024 MosaicML LLM Foundry authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
class VersionedDeprecationWarning(DeprecationWarning): | ||
"""A custom deprecation warning class that includes version information. | ||
Attributes: | ||
message (str): The deprecation message describing why the feature is deprecated. | ||
remove_version (str): The version in which the feature will be removed. | ||
Example: | ||
>>> def deprecated_function(): | ||
... warnings.warn( | ||
... VersionedDeprecationWarning( | ||
... "Function XYZ is deprecated.", | ||
... after_version="2.0.0" | ||
... ) | ||
... ) | ||
... | ||
>>> deprecated_function() | ||
DeprecationWarning: Function XYZ is deprecated. It will be removed in version 2.0.0. | ||
""" | ||
|
||
def __init__(self, message: str, remove_version: str) -> None: | ||
super().__init__(message + | ||
f' It will be removed in version {remove_version}.') |
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