_config.py 843 B

12345678910111213141516171819202122232425262728293031
  1. # SPDX-License-Identifier: MIT
  2. __all__ = ["set_run_validators", "get_run_validators"]
  3. _run_validators = True
  4. def set_run_validators(run):
  5. """
  6. Set whether or not validators are run. By default, they are run.
  7. .. deprecated:: 21.3.0 It will not be removed, but it also will not be
  8. moved to new ``attrs`` namespace. Use `attrs.validators.set_disabled()`
  9. instead.
  10. """
  11. if not isinstance(run, bool):
  12. msg = "'run' must be bool."
  13. raise TypeError(msg)
  14. global _run_validators
  15. _run_validators = run
  16. def get_run_validators():
  17. """
  18. Return whether or not validators are run.
  19. .. deprecated:: 21.3.0 It will not be removed, but it also will not be
  20. moved to new ``attrs`` namespace. Use `attrs.validators.get_disabled()`
  21. instead.
  22. """
  23. return _run_validators