.pre-commit-config.yaml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. default_install_hook_types: ['pre-commit', 'pre-push']
  2. default_stages: [pre-commit]
  3. exclude: >
  4. (?x)(
  5. LICENSE.md$|
  6. \.snap$|
  7. \.map$|
  8. \.map\.js$|
  9. ^src/sentry/static/sentry/vendor/|
  10. ^src/.*/locale/|
  11. ^src/sentry/data/
  12. )
  13. repos:
  14. # Many of these hooks are local because people use a variety of IDEs
  15. # with autoformatters that need to call out to things like `black` directly.
  16. # pre-commit run is not the same, and something like pre-commit exec does
  17. # not exist yet.
  18. - repo: local
  19. hooks:
  20. - id: pyupgrade
  21. name: pyupgrade
  22. entry: pyupgrade
  23. args: ['--py311-plus']
  24. language: system
  25. types: [python]
  26. # Configuration for black exists in pyproject.toml,
  27. # but we let pre-commit take care of the file filtering.
  28. - id: black
  29. name: black
  30. entry: black
  31. language: system
  32. types_or: [python, pyi]
  33. require_serial: true
  34. # Configuration for isort exists in pyproject.toml,
  35. # but we let pre-commit take care of the file filtering.
  36. - id: isort
  37. name: isort
  38. entry: isort
  39. language: system
  40. types: [python]
  41. # Configuration for flake8 exists in setup.cfg,
  42. # but we let pre-commit take care of the file filtering.
  43. - id: flake8
  44. name: flake8
  45. entry: flake8
  46. language: system
  47. types: [python]
  48. log_file: '.artifacts/flake8.pycodestyle.log'
  49. - id: mypy
  50. name: mypy
  51. entry: bash -c 'if [ -n "${SENTRY_MYPY_PRE_PUSH:-}" ]; then exec mypy "$@"; fi' --
  52. language: system
  53. stages: [pre-push]
  54. types: [python]
  55. require_serial: true
  56. - id: lint-requirements
  57. name: lint-requirements
  58. entry: python -m tools.lint_requirements
  59. language: python
  60. files: requirements-.*\.txt$
  61. # exclude the overrides file from this linter -- it doesn't apply at all
  62. exclude: ^requirements-getsentry-overrides\.txt$
  63. additional_dependencies: [packaging==21.3]
  64. - id: requirements-overrides
  65. name: use pinned archives (see comment in file)
  66. stages: [commit]
  67. language: pygrep
  68. entry: |
  69. (?x)
  70. ^
  71. # it's a comment line
  72. (?!\#.*$)
  73. # it's a blank line
  74. (?!$)
  75. # it's a pinned archive
  76. (?![a-z-]+[ ]@[ ]https://github\.com/getsentry/[^/]+/archive/[a-f0-9]{40}\.zip$)
  77. files: ^requirements-getsentry-overrides\.txt$
  78. - id: check-mypy-bypass
  79. name: do not bypass the type checker
  80. entry: '(^# *mypy: *ignore-errors|^# *type: *ignore|\bno_type_check\b)'
  81. language: pygrep
  82. types: [python]
  83. - id: sort-stronger-mypy-list
  84. name: sort stronger mypy list
  85. entry: python3 -m tools.mypy_helpers.sort_stronger_modules
  86. files: ^pyproject\.toml$
  87. language: python
  88. - id: prevent-push
  89. name: prevent pushing master
  90. stages: [pre-push]
  91. entry: bash -c 'test "$PRE_COMMIT_REMOTE_BRANCH" != "refs/heads/master"'
  92. always_run: true
  93. pass_filenames: false
  94. language: system
  95. - repo: https://github.com/pre-commit/pygrep-hooks
  96. rev: v1.10.0
  97. hooks:
  98. - id: python-use-type-annotations
  99. - id: python-check-blanket-type-ignore
  100. - repo: https://github.com/python-jsonschema/check-jsonschema
  101. rev: 0.24.1
  102. hooks:
  103. - id: check-github-actions
  104. - id: check-github-workflows
  105. args: [--verbose]
  106. - repo: https://github.com/pre-commit/pre-commit-hooks
  107. rev: v4.3.0
  108. hooks:
  109. - id: check-case-conflict
  110. - id: check-executables-have-shebangs
  111. - id: check-merge-conflict
  112. - id: check-symlinks
  113. - id: check-yaml
  114. - id: end-of-file-fixer
  115. exclude_types: [svg]
  116. exclude: ^fixtures/
  117. - id: trailing-whitespace
  118. exclude_types: [svg]
  119. exclude: ^(fixtures/|scripts/patches/)
  120. - id: debug-statements
  121. - id: name-tests-test
  122. args: [--pytest-test-first]
  123. - repo: https://github.com/biomejs/pre-commit
  124. rev: v0.1.0
  125. hooks:
  126. - id: biome-check
  127. name: biome (javascript, typescript, json)
  128. additional_dependencies: ['@biomejs/biome@1.6.0']
  129. - repo: https://github.com/pre-commit/mirrors-prettier
  130. rev: 'v3.1.0' # Use the sha or tag you want to point at
  131. hooks:
  132. - id: prettier
  133. name: prettier (yaml, markdown, tsx, jsx, css)
  134. # TODO: Remove tsx and jsx when Biome supports styled CSS formatting.
  135. types_or: [yaml, markdown, tsx, jsx, css]
  136. # Override the default version of prettier since there isn't a tag with 3.2.5
  137. additional_dependencies: ['prettier@3.2.5']
  138. # https://pre-commit.com/#regular-expressions
  139. exclude: |
  140. (?x)^($^
  141. # prettier crashes on some of these, by intent:
  142. |fixtures/.*
  143. # these have enormous diffs when formatted:
  144. |api-docs/paths/events/issue-hashes\.json
  145. |api-docs/paths/events/latest-event\.json
  146. |api-docs/paths/events/oldest-event\.json
  147. |api-docs/paths/events/project-event-details\.json
  148. |src/sentry/issues/event\.schema\.json
  149. |static/app/data/world\.json
  150. |static/app/utils/profiling/profile/formats/android/trace\.json
  151. |static/app/utils/profiling/profile/formats/ios/trace\.json
  152. |static/app/utils/profiling/profile/formats/node/trace\.json
  153. |static/app/utils/profiling/profile/formats/typescript/trace\.json
  154. )$
  155. - repo: https://github.com/shellcheck-py/shellcheck-py
  156. rev: v0.9.0.6
  157. hooks:
  158. - id: shellcheck
  159. types: [file]
  160. files: ^\.envrc$
  161. args: [--external-sources]