run_pytype.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env vpython3
  2. # Copyright 2022 The 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. """Simple helper script to run pytype on Gold Python code."""
  6. import os
  7. import sys
  8. GOLD_DIR = os.path.abspath(os.path.dirname(__file__))
  9. CHROMIUM_SRC_DIR = os.path.realpath(os.path.join(GOLD_DIR, '..', '..'))
  10. sys.path.append(os.path.join(CHROMIUM_SRC_DIR, 'testing'))
  11. from pytype_common import pytype_runner # pylint: disable=wrong-import-position
  12. EXTRA_PATHS_COMPONENTS = [
  13. ('build', ),
  14. ('testing', ),
  15. ]
  16. EXTRA_PATHS = [
  17. os.path.join(CHROMIUM_SRC_DIR, *p) for p in EXTRA_PATHS_COMPONENTS
  18. ]
  19. EXTRA_PATHS.append(GOLD_DIR)
  20. FILES_AND_DIRECTORIES_TO_CHECK = [
  21. '.',
  22. ]
  23. FILES_AND_DIRECTORIES_TO_CHECK = [
  24. os.path.join(GOLD_DIR, f) for f in FILES_AND_DIRECTORIES_TO_CHECK
  25. ]
  26. TEST_NAME = 'gold_common_pytype'
  27. TEST_LOCATION = '//build/skia_gold_common/run_pytype.py'
  28. def main() -> int:
  29. return pytype_runner.run_pytype(TEST_NAME, TEST_LOCATION,
  30. FILES_AND_DIRECTORIES_TO_CHECK, EXTRA_PATHS,
  31. GOLD_DIR)
  32. if __name__ == '__main__':
  33. sys.exit(main())