cli.py 599 B

123456789101112131415161718192021222324
  1. """Command-line implementation of flake8."""
  2. from __future__ import annotations
  3. import sys
  4. from typing import Sequence
  5. from flake8.main import application
  6. def main(argv: Sequence[str] | None = None) -> int:
  7. """Execute the main bit of the application.
  8. This handles the creation of an instance of :class:`Application`, runs it,
  9. and then exits the application.
  10. :param argv:
  11. The arguments to be passed to the application for parsing.
  12. """
  13. if argv is None:
  14. argv = sys.argv[1:]
  15. app = application.Application()
  16. app.run(argv)
  17. return app.exit_code()