run_utils_pylint.py 1.6 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('--show-locally-disabled',
  15. action='store_true',
  16. help='Show "locally-disabled" Pylint warnings.')
  17. args = parser.parse_args()
  18. disable = ['bad-continuation']
  19. if args.hide_fixme:
  20. disable.append('fixme')
  21. if not args.show_locally_disabled:
  22. disable.append('locally-disabled')
  23. pylint_options = [
  24. '--disable={}'.format(','.join(disable)),
  25. '--jobs=4',
  26. '--score=n',
  27. '--persistent=n',
  28. ]
  29. ignore_prefixes = [
  30. ('third_party', ),
  31. ('tests', ),
  32. ]
  33. sys.path.insert(1, str(Path(__file__).resolve().parent.parent / 'utils' / 'third_party'))
  34. sys.path.append(Path(__file__).resolve().parent.parent / 'utils')
  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. sys.exit(1)
  44. sys.exit(0)
  45. if __name__ == '__main__':
  46. main()