-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reformat utils * Remove unused _convert_angles function * Remove check for numba install * Clean up unused variables, add typing * Remove unused _coo_build_window function * Add type hints to function defs * Remove unnecessary variables / passes * Provide deprecation warnings to the user. * Tuple -> tuple * List -> list, Dict -> dict * Change deprecated to accept str instead of func * Remove unnecessary "save" func from etaOmeMaps * Add deprecation date * deprecation_date -> removal_date * Swap max/min energies for wavelength calc
- Loading branch information
Zack
authored
Jul 3, 2024
1 parent
3115df3
commit 8119695
Showing
3 changed files
with
688 additions
and
700 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
import functools | ||
|
||
|
||
class DeprecatedFunctionError(Exception): | ||
"""Custom exception for deprecated functions.""" | ||
pass | ||
|
||
|
||
def deprecated(new_func: str = None, removal_date: str = None): | ||
""" | ||
Decorator to mark functions as deprecated. Raises an error if | ||
the 'ACK_DEPRECATED' environment variable is not set. Alerts the | ||
user to the replacement function if provided. | ||
""" | ||
|
||
def decorator(func): | ||
@functools.wraps(func) | ||
def wrapper(*args, **kwargs): | ||
if new_func is not None: | ||
print( | ||
f"Warning: {func.__name__} is deprecated and is marked for" | ||
f" removal. Please use {new_func} instead." | ||
f" Removal date: {removal_date}" | ||
) | ||
if os.getenv('ACK_DEPRECATED') != 'true': | ||
raise DeprecatedFunctionError( | ||
f"Function {func.__name__} is deprecated. Set environment " | ||
"variable 'ACK_DEPRECATED' to 'true' to acknowledge." | ||
) | ||
return func(*args, **kwargs) | ||
|
||
return wrapper | ||
|
||
return decorator |
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
Oops, something went wrong.