interfaces.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  2. # For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
  3. # Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
  4. from __future__ import annotations
  5. from typing import NamedTuple
  6. __all__ = (
  7. "CONFIDENCE_LEVELS",
  8. "CONFIDENCE_LEVEL_NAMES",
  9. "CONTROL_FLOW",
  10. "HIGH",
  11. "INFERENCE",
  12. "INFERENCE_FAILURE",
  13. "UNDEFINED",
  14. )
  15. class Confidence(NamedTuple):
  16. name: str
  17. description: str
  18. # Warning Certainties
  19. HIGH = Confidence("HIGH", "Warning that is not based on inference result.")
  20. CONTROL_FLOW = Confidence(
  21. "CONTROL_FLOW", "Warning based on assumptions about control flow."
  22. )
  23. INFERENCE = Confidence("INFERENCE", "Warning based on inference result.")
  24. INFERENCE_FAILURE = Confidence(
  25. "INFERENCE_FAILURE", "Warning based on inference with failures."
  26. )
  27. UNDEFINED = Confidence("UNDEFINED", "Warning without any associated confidence level.")
  28. CONFIDENCE_LEVELS = [HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, UNDEFINED]
  29. CONFIDENCE_LEVEL_NAMES = [i.name for i in CONFIDENCE_LEVELS]
  30. CONFIDENCE_MAP = {i.name: i for i in CONFIDENCE_LEVELS}