.pre-commit-config.yaml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. default_install_hook_types: ["pre-commit", "pre-push"]
  2. exclude: >
  3. (?x)(
  4. LICENSE$|
  5. \.snap$|
  6. \.map$|
  7. \.map\.js$|
  8. ^src/sentry/static/sentry/vendor/|
  9. ^src/.*/locale/|
  10. ^src/sentry/data/
  11. )
  12. repos:
  13. # Many of these hooks are local because people use a variety of IDEs
  14. # with autoformatters that need to call out to things like `black` directly.
  15. # pre-commit run is not the same, and something like pre-commit exec does
  16. # not exist yet.
  17. - repo: local
  18. hooks:
  19. - id: pyupgrade
  20. name: pyupgrade
  21. entry: pyupgrade
  22. args: ['--py38-plus', '--keep-runtime-typing']
  23. language: system
  24. types: [python]
  25. # Configuration for black exists in pyproject.toml,
  26. # but we let pre-commit take care of the file filtering.
  27. - id: black
  28. name: black
  29. entry: black
  30. language: system
  31. types: [python]
  32. require_serial: true
  33. # Configuration for isort exists in pyproject.toml,
  34. # but we let pre-commit take care of the file filtering.
  35. - id: isort
  36. name: isort
  37. entry: isort
  38. language: system
  39. types: [python]
  40. # Configuration for flake8 exists in setup.cfg,
  41. # but we let pre-commit take care of the file filtering.
  42. - id: flake8
  43. name: flake8
  44. entry: flake8
  45. language: system
  46. types: [python]
  47. log_file: '.artifacts/flake8.pycodestyle.log'
  48. - id: lint-requirements
  49. name: lint-requirements
  50. entry: python -m tools.lint_requirements
  51. language: python
  52. files: requirements-.*\.txt$
  53. additional_dependencies: [packaging==21.3]
  54. - id: check-mypy-bypass
  55. name: do not bypass the type checker
  56. entry: '(^# *mypy: *ignore-errors|^# *type: *ignore|\bno_type_check\b)'
  57. language: pygrep
  58. types: [python]
  59. exclude: ^src/sentry/metrics/minimetrics.py$
  60. - id: prevent-push
  61. name: prevent pushing master
  62. stages: [pre-push]
  63. entry: bash -c 'test "$PRE_COMMIT_REMOTE_BRANCH" != "refs/heads/master"'
  64. always_run: true
  65. pass_filenames: false
  66. language: system
  67. - repo: https://github.com/pre-commit/pygrep-hooks
  68. rev: v1.10.0
  69. hooks:
  70. - id: python-use-type-annotations
  71. - repo: https://github.com/python-jsonschema/check-jsonschema
  72. rev: 0.24.1
  73. hooks:
  74. - id: check-github-actions
  75. - id: check-github-workflows
  76. args: [--verbose]
  77. - repo: https://github.com/pre-commit/pre-commit-hooks
  78. rev: v4.3.0
  79. hooks:
  80. - id: check-case-conflict
  81. - id: check-executables-have-shebangs
  82. - id: check-merge-conflict
  83. - id: check-symlinks
  84. - id: check-yaml
  85. - id: end-of-file-fixer
  86. exclude_types: [svg]
  87. exclude: ^fixtures/
  88. - id: trailing-whitespace
  89. exclude_types: [svg]
  90. exclude: ^(fixtures/|scripts/patches/)
  91. - id: debug-statements
  92. - id: name-tests-test
  93. args: [--pytest-test-first]