_config.py 892 B

123456789101112131415161718192021222324252627282930313233
  1. # SPDX-License-Identifier: MIT
  2. from __future__ import absolute_import, division, print_function
  3. __all__ = ["set_run_validators", "get_run_validators"]
  4. _run_validators = True
  5. def set_run_validators(run):
  6. """
  7. Set whether or not validators are run. By default, they are run.
  8. .. deprecated:: 21.3.0 It will not be removed, but it also will not be
  9. moved to new ``attrs`` namespace. Use `attrs.validators.set_disabled()`
  10. instead.
  11. """
  12. if not isinstance(run, bool):
  13. raise TypeError("'run' must be bool.")
  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