This commit is contained in:
Max Bachmann 2023-04-12 12:20:16 +02:00
parent 692538140a
commit 867fb6179b
7 changed files with 1728 additions and 1717 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ test.py
src/*.html
.coverage
coverage.xml
sde/
# Sphinx documentation
site/

View File

@ -30,19 +30,6 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
# Upgrade old Python syntax
- repo: https://github.com/asottile/pyupgrade
rev: "v3.3.1"
hooks:
- id: pyupgrade
args: [--py37-plus]
# Nicely sort includes
- repo: https://github.com/PyCQA/isort
rev: "5.12.0"
hooks:
- id: isort
# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black
rev: "23.3.0" # Keep in sync with blacken-docs
@ -69,41 +56,15 @@ repos:
- id: fix-ligatures
- id: fix-smartquotes
# Autoremoves unused imports
- repo: https://github.com/hadialqattan/pycln
rev: "v2.1.3"
hooks:
- id: pycln
stages: [manual]
# Checking for common mistakes
- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-no-log-warn
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
# Automatically remove noqa that are not used
- repo: https://github.com/asottile/yesqa
rev: "v1.4.0"
hooks:
- id: yesqa
additional_dependencies: &flake8_dependencies
- flake8-bugbear
- pep8-naming
# Flake8 also supports pre-commit natively (same author)
- repo: https://github.com/PyCQA/flake8
rev: "6.0.0"
hooks:
- id: flake8
exclude: ^(docs/.*|tools/.*)$
additional_dependencies: *flake8_dependencies
# PyLint has native support - not always usable, but works for us
- repo: https://github.com/PyCQA/pylint
@ -139,9 +100,13 @@ repos:
stages: [manual]
additional_dependencies: [cmake, ninja]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.261
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
# Check for spelling
# Use tools/codespell_ignore_lines_from_errors.py
# to rebuild .codespell-ignore-lines
- repo: https://github.com/codespell-project/codespell
rev: "v2.2.4"
hooks:

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 33 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -7,26 +7,26 @@ requires = [
build-backend = "backend"
backend-path = ["_custom_build"]
[tool.isort]
profile = "black"
[tool.mypy]
files = "src"
files = ["src"]
python_version = "3.7"
strict = true
warn_unused_configs = true
show_error_codes = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true
strict = true
disallow_untyped_defs = false
[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests"]
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
norecursedirs = ["_skbuild"]
xfail_strict = true
log_cli_level = "info"
testpaths = ["tests"]
[tool.pylint.master]
py-version = "3.6"
[tool.pylint]
py-version = "3.7"
[tool.pylint.reports]
output-format = "colorized"
@ -42,3 +42,52 @@ disable = [
"protected-access",
"missing-module-docstring",
]
[tool.ruff]
select = [
"E", "F", "W", # flake8
"B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"G", # flake8-logging-format
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"RET", # flake8-return
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020
"EXE", # flake8-executable
"NPY", # NumPy specific rules
"PD", # pandas-vet
]
extend-ignore = [
"PLR", # Design related pylint codes
"E501", # Line too long
"PT004", # Use underscore for non-returning fixture (use usefixture instead)
"PTH123", # use pathlib instead of builtin open
]
target-version = "py37"
src = ["src"]
unfixable = [
"T20", # Removes print statements
"F841", # Removes unused variables
]
exclude = []
flake8-unused-arguments.ignore-variadic-names = true
isort.required-imports = ["from __future__ import annotations"]
[tool.ruff.per-file-ignores]
"tests/**" = ["T20"]
"bench/**" = ["T20"]
"_custom_build/backend.py" = ["T20"]
"setup.py" = ["T20"]

View File

@ -1,6 +0,0 @@
[flake8]
max-line-length = 120
show_source = True
exclude = .git, __pycache__, build, dist, docs, tools, venv
extend-ignore = E203, E722, B903, B950, N801, N802, N806, B905, B907
extend-select = B9

View File

@ -17,9 +17,9 @@ def test_editops_comparison():
"""
ops = Levenshtein.editops("aaabaaa", "abbaaabba")
assert ops == ops
assert not (ops != ops) # noqa
assert not (ops != ops) # noqa: SIM202
assert ops == ops.copy()
assert not (ops != ops.copy()) # noqa
assert not (ops != ops.copy()) # noqa: SIM202
@pytest.mark.parametrize("module", [distance_py, distance_cpp])
@ -99,10 +99,12 @@ def test_editops_get_slice(module):
assert ops[-3:].as_list() == ops_list[-3:]
assert ops[-3:-1].as_list() == ops_list[-3:-1]
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="slice step cannot be zero"):
ops[::0]
with pytest.raises(ValueError):
with pytest.raises(
ValueError, match="step sizes below 0 lead to an invalid order of editops"
):
ops[::-1]
@ -185,9 +187,9 @@ def test_opcodes_comparison():
"""
ops = Levenshtein.opcodes("aaabaaa", "abbaaabba")
assert ops == ops
assert not (ops != ops) # noqa
assert not (ops != ops) # noqa: SIM202
assert ops == ops.copy()
assert not (ops != ops.copy()) # noqa
assert not (ops != ops.copy()) # noqa: SIM202
@pytest.mark.parametrize("module", [distance_py, distance_cpp])