run_utils_pylint.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. '--max-args=7',
  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. sys.path.append(Path(__file__).resolve().parent.parent / 'utils')
  36. with ChangeDir(Path(__file__).resolve().parent.parent / 'utils'):
  37. result = run_pylint(
  38. Path(),
  39. pylint_options,
  40. ignore_prefixes=ignore_prefixes,
  41. )
  42. sys.path.pop(1)
  43. if not result:
  44. sys.exit(1)
  45. sys.exit(0)
  46. if __name__ == '__main__':
  47. main()