Skip to content

Commit

Permalink
Simplify linting
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Oct 31, 2024
1 parent 1176780 commit 0589cf6
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 43 deletions.
3 changes: 2 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
- 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.
If you don't, [CI] will catch it for you – but that seems like a waste of your time!

Expand Down
37 changes: 5 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,13 @@
ci:
autoupdate_schedule: monthly

default_language_version:
python: python3.12

repos:
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
language_version: python3.10

- 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
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/econchick/interrogate
rev: 1.7.0
Expand All @@ -46,7 +20,6 @@ repos:
rev: v2.3.0
hooks:
- id: codespell
args: [-L, alog]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
Expand Down
54 changes: 46 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,54 @@ testpaths = "tests"
filterwarnings = ["once::Warning"]


[tool.black]
line-length = 79


[tool.isort]
profile = "attrs"


[tool.interrogate]
omit-covered-files = true
verbose = 2
fail-under = 100
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
2 changes: 1 addition & 1 deletion src/_argon2_cffi_bindings/_ffi_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _get_target_platform(arch_flags, default):
"_ffi",
"#include <argon2.h>",
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=[
str(lib_base / path)
for path in [
Expand Down
2 changes: 1 addition & 1 deletion tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


@pytest.mark.parametrize(
"arch_flags, expected",
("arch_flags", "expected"),
[
(" -arch arm64", "arm64"),
("abc -arch arm64 xyz", "arm64"),
Expand Down

0 comments on commit 0589cf6

Please sign in to comment.