.pre-commit-config.yaml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. # exclude the overrides file from this linter -- it doesn't apply at all
  54. exclude: ^requirements-getsentry-overrides\.txt$
  55. additional_dependencies: [packaging==21.3]
  56. - id: check-mypy-bypass
  57. name: do not bypass the type checker
  58. entry: '(^# *mypy: *ignore-errors|^# *type: *ignore|\bno_type_check\b)'
  59. language: pygrep
  60. types: [python]
  61. exclude: ^src/sentry/metrics/minimetrics.py$
  62. - id: prevent-push
  63. name: prevent pushing master
  64. stages: [pre-push]
  65. entry: bash -c 'test "$PRE_COMMIT_REMOTE_BRANCH" != "refs/heads/master"'
  66. always_run: true
  67. pass_filenames: false
  68. language: system
  69. - repo: https://github.com/pre-commit/pygrep-hooks
  70. rev: v1.10.0
  71. hooks:
  72. - id: python-use-type-annotations
  73. - repo: https://github.com/python-jsonschema/check-jsonschema
  74. rev: 0.24.1
  75. hooks:
  76. - id: check-github-actions
  77. - id: check-github-workflows
  78. args: [--verbose]
  79. - repo: https://github.com/pre-commit/pre-commit-hooks
  80. rev: v4.3.0
  81. hooks:
  82. - id: check-case-conflict
  83. - id: check-executables-have-shebangs
  84. - id: check-merge-conflict
  85. - id: check-symlinks
  86. - id: check-yaml
  87. - id: end-of-file-fixer
  88. exclude_types: [svg]
  89. exclude: ^fixtures/
  90. - id: trailing-whitespace
  91. exclude_types: [svg]
  92. exclude: ^(fixtures/|scripts/patches/)
  93. - id: debug-statements
  94. - id: name-tests-test
  95. args: [--pytest-test-first]