setup.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. """Everything related to the setup of the 'pylint-config' command."""
  5. from __future__ import annotations
  6. import argparse
  7. from collections.abc import Sequence
  8. from typing import Any
  9. from pylint.config._pylint_config.help_message import get_help
  10. from pylint.config.callback_actions import _AccessParserAction
  11. class _HelpAction(_AccessParserAction):
  12. def __call__(
  13. self,
  14. parser: argparse.ArgumentParser,
  15. namespace: argparse.Namespace,
  16. values: str | Sequence[Any] | None,
  17. option_string: str | None = "--help",
  18. ) -> None:
  19. get_help(self.parser)
  20. def _register_generate_config_options(parser: argparse.ArgumentParser) -> None:
  21. """Registers the necessary arguments on the parser."""
  22. parser.prog = "pylint-config"
  23. # Overwrite the help command
  24. parser.add_argument(
  25. "-h",
  26. "--help",
  27. action=_HelpAction,
  28. default=argparse.SUPPRESS,
  29. help="show this help message and exit",
  30. parser=parser,
  31. )
  32. # We use subparsers to create various subcommands under 'pylint-config'
  33. subparsers = parser.add_subparsers(dest="config_subcommand", title="Subcommands")
  34. # Add the generate command
  35. generate_parser = subparsers.add_parser(
  36. "generate", help="Generate a pylint configuration"
  37. )
  38. generate_parser.add_argument("--interactive", action="store_true")