deprecations.py 600 B

1234567891011121314151617181920212223242526
  1. """
  2. Utility module useful for refactors,
  3. Defines utility function for easy raising of warnings in deprecated functions.
  4. This function is set to use stacklevel 3 as default making following code in test.py:
  5. def depreacted_function():
  6. warn("This function is deprecated")
  7. def other_function():
  8. deprecated_function()
  9. Will raise warning about 1st line in other_function calling deprecated function.
  10. """
  11. import warnings
  12. class RemovedInMisagoWarning(Warning):
  13. pass
  14. def warn(message, category=RemovedInMisagoWarning, stacklevel=0):
  15. warnings.warn(message, category, stacklevel + 3)