mapreduce_checker.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  2. # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
  3. # Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
  4. from __future__ import annotations
  5. import abc
  6. import warnings
  7. from typing import TYPE_CHECKING, Any
  8. if TYPE_CHECKING:
  9. from pylint.lint import PyLinter
  10. class MapReduceMixin(metaclass=abc.ABCMeta):
  11. """A mixin design to allow multi-process/threaded runs of a Checker."""
  12. def __init__(self) -> None:
  13. warnings.warn(
  14. "MapReduceMixin has been deprecated and will be removed in pylint 3.0. "
  15. "To make a checker reduce map data simply implement get_map_data and reduce_map_data.",
  16. DeprecationWarning,
  17. stacklevel=2,
  18. )
  19. @abc.abstractmethod
  20. def get_map_data(self) -> Any:
  21. """Returns merge-able/reducible data that will be examined."""
  22. @abc.abstractmethod
  23. def reduce_map_data(self, linter: PyLinter, data: list[Any]) -> None:
  24. """For a given Checker, receives data for all mapped runs."""