base.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. from abc import ABC, abstractmethod
  2. from typing import Iterable, List, Optional, Tuple
  3. from prospector.message import Message
  4. class ToolBase(ABC):
  5. @abstractmethod
  6. def configure(self, prospector_config, found_files) -> Tuple[str, Optional[Iterable[Message]]]:
  7. """
  8. Tools have their own way of being configured from configuration files
  9. on the current path - for example, a .pep8rc file. Prospector will use
  10. its own configuration settings unless this method discovers some
  11. tool-specific configuration that should be used instead.
  12. :return: A tuple: the first element is a string indicating how or where
  13. this tool was configured from. For example, this can be a path
  14. to the .pylintrc file used, if used. None means that prospector
  15. defaults were used. The second element should be an iterable of
  16. Message objects representing any issues which were found when
  17. trying to load configuration - for example, bad values in a
  18. .pylintrc file. It is also possible to simply return None if
  19. neither value is useful.
  20. """
  21. raise NotImplementedError
  22. @abstractmethod
  23. def run(self, found_files) -> List[Message]:
  24. """
  25. Actually run the tool and collect the various messages emitted by the tool.
  26. It is expected that this will convert whatever output of the tool into the
  27. standard prospector Message and Location objects.
  28. """
  29. raise NotImplementedError