add pre-commit

This commit is contained in:
kosarevskiydp 2023-03-12 09:31:02 +03:00
parent 9e5fc2fd93
commit 8df595f139
2 changed files with 111 additions and 0 deletions

74
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,74 @@
#default_language_version:
# python: python3.10.8
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: [ ]
submodules: false
default_stages: [ commit, push ]
files: ^(src/)
exclude_types: [ css, toml, template ]
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- id: detect-private-key
- id: check-docstring-first
- id: requirements-txt-fixer
- id: debug-statements
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.254
hooks:
- id: ruff
- repo: https://github.com/abravalheri/validate-pyproject
rev: e22efabdc7203a4a6388231f8052c296cbb6eb8d
hooks:
- id: validate-pyproject
- repo: https://github.com/pre-commit/mirrors-pylint
rev: a1b176a5ee919967cf01e87c0222bd64b94fe0de
hooks:
- id: pylint
args:
- --max-line-length=120
- --ignore-imports=yes
- -d duplicate-code
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-mock-methods
- id: python-use-type-annotations
- id: python-check-blanket-noqa
- id: python-use-type-annotations
- id: text-unicode-replacement-char
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
additional_dependencies: [ types-PyYAML==6.0.10, types_requests==2.28.8, types-ujson==5.5.0 ]
args: [ --ignore-missing-imports, --warn-no-return, --warn-redundant-casts, --disallow-incomplete-defs ]
- repo: https://github.com/sourcery-ai/sourcery
rev: v1.0.1
hooks:
- id: sourcery
# The best way to use Sourcery in a pre-commit hook
# is to review only changed lines:
args: [ --diff=git diff HEAD ]

37
pyproject.toml Normal file
View File

@ -0,0 +1,37 @@
[tool.ruff]
line-length = 120
# Enable Flake's "E" and "F" codes by default.
select = ["E", "F", "U", "N", "S", "C", "B", "A", "Q", "A", "YTT", "RUF", "M", "W", "I" ]
ignore = ["N806", "S101", "A003", "N815", "S104"]
# Exclude a variety of commonly ignored directories.
exclude = [".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
".idea",
".streamlit",
]
per-file-ignores = { }
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Assume Python 3.10.
target-version = "py310"