Simplify linting (#73)
This commit is contained in:
parent
1176780bec
commit
20e2010519
3
.github/CONTRIBUTING.md
vendored
3
.github/CONTRIBUTING.md
vendored
@ -119,7 +119,8 @@ $ pre-commit run --all-files
|
|||||||
"""
|
"""
|
||||||
```
|
```
|
||||||
- If you add or change public APIs, tag the docstring using `.. versionadded:: 16.0.0 WHAT` or `.. versionchanged:: 16.2.0 WHAT`.
|
- If you add or change public APIs, tag the docstring using `.. versionadded:: 16.0.0 WHAT` or `.. versionchanged:: 16.2.0 WHAT`.
|
||||||
- We use [*isort*](https://github.com/PyCQA/isort) to sort our imports, and we use [*Black*](https://github.com/psf/black) with line length of 79 characters to format our code.
|
|
||||||
|
- We use [Ruff](https://ruff.rs/) to sort our imports and format our code with a line length of 79 characters.
|
||||||
As long as you run our full [*tox*] suite before committing, or install our [*pre-commit*] hooks (ideally you'll do both – see [*Local Development Environment*](#local-development-environment) above), you won't have to spend any time on formatting your code at all.
|
As long as you run our full [*tox*] suite before committing, or install our [*pre-commit*] hooks (ideally you'll do both – see [*Local Development Environment*](#local-development-environment) above), you won't have to spend any time on formatting your code at all.
|
||||||
If you don't, [CI] will catch it for you – but that seems like a waste of your time!
|
If you don't, [CI] will catch it for you – but that seems like a waste of your time!
|
||||||
|
|
||||||
|
|||||||
@ -2,39 +2,13 @@
|
|||||||
ci:
|
ci:
|
||||||
autoupdate_schedule: monthly
|
autoupdate_schedule: monthly
|
||||||
|
|
||||||
default_language_version:
|
|
||||||
python: python3.12
|
|
||||||
|
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: 24.10.0
|
rev: v0.7.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: ruff
|
||||||
language_version: python3.10
|
args: [--fix, --exit-non-zero-on-fix]
|
||||||
|
- id: ruff-format
|
||||||
- repo: https://github.com/PyCQA/isort
|
|
||||||
rev: 5.13.2
|
|
||||||
hooks:
|
|
||||||
- id: isort
|
|
||||||
additional_dependencies: [toml]
|
|
||||||
|
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
|
||||||
rev: v3.18.0
|
|
||||||
hooks:
|
|
||||||
- id: pyupgrade
|
|
||||||
args: [--py37-plus]
|
|
||||||
|
|
||||||
- repo: https://github.com/asottile/yesqa
|
|
||||||
rev: v1.5.0
|
|
||||||
hooks:
|
|
||||||
- id: yesqa
|
|
||||||
additional_dependencies: [flake8-bugbear]
|
|
||||||
|
|
||||||
- repo: https://github.com/PyCQA/flake8
|
|
||||||
rev: 7.1.1
|
|
||||||
hooks:
|
|
||||||
- id: flake8
|
|
||||||
additional_dependencies: [flake8-bugbear]
|
|
||||||
|
|
||||||
- repo: https://github.com/econchick/interrogate
|
- repo: https://github.com/econchick/interrogate
|
||||||
rev: 1.7.0
|
rev: 1.7.0
|
||||||
@ -46,7 +20,6 @@ repos:
|
|||||||
rev: v2.3.0
|
rev: v2.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: codespell
|
- id: codespell
|
||||||
args: [-L, alog]
|
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v5.0.0
|
rev: v5.0.0
|
||||||
|
|||||||
@ -66,16 +66,54 @@ testpaths = "tests"
|
|||||||
filterwarnings = ["once::Warning"]
|
filterwarnings = ["once::Warning"]
|
||||||
|
|
||||||
|
|
||||||
[tool.black]
|
|
||||||
line-length = 79
|
|
||||||
|
|
||||||
|
|
||||||
[tool.isort]
|
|
||||||
profile = "attrs"
|
|
||||||
|
|
||||||
|
|
||||||
[tool.interrogate]
|
[tool.interrogate]
|
||||||
omit-covered-files = true
|
omit-covered-files = true
|
||||||
verbose = 2
|
verbose = 2
|
||||||
fail-under = 100
|
fail-under = 100
|
||||||
whitelist-regex = ["test_.*"]
|
whitelist-regex = ["test_.*"]
|
||||||
|
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
src = ["src", "tests"]
|
||||||
|
line-length = 79
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
select = ["ALL"]
|
||||||
|
ignore = [
|
||||||
|
"A001", # shadowing is fine
|
||||||
|
"A002", # shadowing is fine
|
||||||
|
"A003", # shadowing is fine
|
||||||
|
"ANN", # Mypy is better at this
|
||||||
|
"ARG001", # unused arguments are normal when implementing interfaces
|
||||||
|
"COM", # Formatter takes care of our commas
|
||||||
|
"D", # We prefer our own docstring style.
|
||||||
|
"E501", # leave line-length enforcement to formatter
|
||||||
|
"ERA001", # Dead code detection is overly eager.
|
||||||
|
"FBT", # we have one function that takes one bool; c'mon!
|
||||||
|
"FIX", # Yes, we want XXX as a marker.
|
||||||
|
"INP001", # sometimes we want Python files outside of packages
|
||||||
|
"ISC001", # conflicts with ruff format
|
||||||
|
"PLR0913", # yes, many arguments, but most have defaults
|
||||||
|
"PLR2004", # numbers are sometimes fine
|
||||||
|
"PLW2901", # re-assigning within loop bodies is fine
|
||||||
|
"RUF001", # leave my smart characters alone
|
||||||
|
"SLF001", # private members are accessed by friendly functions
|
||||||
|
"TCH", # TYPE_CHECKING blocks break autodocs
|
||||||
|
"TD", # we don't follow other people's todo style
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.ruff.lint.per-file-ignores]
|
||||||
|
"src/argon2/__main__.py" = ["T201"] # need print in CLI
|
||||||
|
"tests/*" = [
|
||||||
|
"ARG", # stubs don't care about arguments
|
||||||
|
"S101", # assert
|
||||||
|
"SIM300", # Yoda rocks in asserts
|
||||||
|
"PT005", # we always add underscores and explicit name
|
||||||
|
"PT011", # broad is fine
|
||||||
|
"TRY002", # stock exceptions are fine in tests
|
||||||
|
"EM101", # no need for exception msg hygiene in tests
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.ruff.lint.isort]
|
||||||
|
lines-between-types = 1
|
||||||
|
lines-after-imports = 2
|
||||||
|
|||||||
@ -55,7 +55,7 @@ else:
|
|||||||
"_ffi",
|
"_ffi",
|
||||||
"#include <argon2.h>",
|
"#include <argon2.h>",
|
||||||
extra_compile_args=["-msse2"] if (optimized and not windows) else None,
|
extra_compile_args=["-msse2"] if (optimized and not windows) else None,
|
||||||
include_dirs=[os.path.join("extras", "libargon2", "include")],
|
include_dirs=[str(Path("extras", "libargon2", "include"))],
|
||||||
sources=[
|
sources=[
|
||||||
str(lib_base / path)
|
str(lib_base / path)
|
||||||
for path in [
|
for path in [
|
||||||
|
|||||||
@ -4,7 +4,7 @@ from _argon2_cffi_bindings._ffi_build import _get_target_platform
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"arch_flags, expected",
|
("arch_flags", "expected"),
|
||||||
[
|
[
|
||||||
(" -arch arm64", "arm64"),
|
(" -arch arm64", "arm64"),
|
||||||
("abc -arch arm64 xyz", "arm64"),
|
("abc -arch arm64 xyz", "arm64"),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user