run_utils_pylint.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env python3
  2. # Copyright (c) 2019 The ungoogled-chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """Run Pylint over utils"""
  6. import argparse
  7. import sys
  8. from pathlib import Path
  9. from run_other_pylint import ChangeDir, run_pylint
  10. def main():
  11. """CLI entrypoint"""
  12. parser = argparse.ArgumentParser(description='Run Pylint over utils')
  13. parser.add_argument('--hide-fixme', action='store_true', help='Hide "fixme" Pylint warnings.')
  14. parser.add_argument(
  15. '--show-locally-disabled',
  16. action='store_true',
  17. help='Show "locally-disabled" Pylint warnings.')
  18. args = parser.parse_args()
  19. disable = ['bad-continuation']
  20. if args.hide_fixme:
  21. disable.append('fixme')
  22. if not args.show_locally_disabled:
  23. disable.append('locally-disabled')
  24. pylint_options = [
  25. '--disable={}'.format(','.join(disable)),
  26. '--jobs=4',
  27. '--score=n',
  28. '--persistent=n',
  29. ]
  30. ignore_prefixes = [
  31. ('third_party', ),
  32. ('tests', ),
  33. ]
  34. sys.path.insert(1, str(Path(__file__).resolve().parent.parent / 'utils' / 'third_party'))
  35. with ChangeDir(Path(__file__).resolve().parent.parent / 'utils'):
  36. result = run_pylint(
  37. Path(),
  38. pylint_options,
  39. ignore_prefixes=ignore_prefixes,
  40. )
  41. sys.path.pop(1)
  42. if not result:
  43. exit(1)
  44. exit(0)
  45. if __name__ == '__main__':
  46. main()