Skip to content

Commit 36f5eed

Browse files
committed
chore(pre-commit): update configuration and remove isort
1 parent 76a7331 commit 36f5eed

5 files changed

Lines changed: 86 additions & 18 deletions

File tree

.pre-commit-config.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ repos:
1717
- id: trailing-whitespace
1818
- id: no-commit-to-branch
1919
args: [ --branch, master ]
20-
- repo: https://github.com/pycqa/isort
21-
rev: 9.0.0a3
22-
hooks:
23-
- id: isort
2420
- repo: https://github.com/asottile/add-trailing-comma
2521
rev: v4.0.0
2622
hooks:
@@ -30,13 +26,16 @@ repos:
3026
hooks:
3127
- id: ruff
3228
args: [ --fix, --exit-non-zero-on-fix ]
33-
- repo: https://github.com/psf/black
34-
rev: 26.5.1
35-
hooks:
36-
- id: black
29+
- id: ruff-format
3730
- repo: https://github.com/pappasam/toml-sort
3831
rev: v0.24.4
3932
hooks:
4033
- id: toml-sort
4134
entry: toml-sort
4235
args: [ pyproject.toml ]
36+
- repo: https://github.com/compilerla/conventional-pre-commit
37+
rev: v4.4.0
38+
hooks:
39+
- id: conventional-pre-commit
40+
stages: [commit-msg]
41+
args: [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test]

CONTRIBUTING.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Contributing
2+
3+
## Setup
4+
5+
```bash
6+
# Install all dependency groups (dev, docs, test)
7+
uv sync
8+
9+
# Install pre-commit hooks
10+
uv run pre-commit install --hook-type pre-commit --hook-type commit-msg
11+
```
12+
13+
## Development workflow
14+
15+
```bash
16+
# Run tests
17+
uv run pytest
18+
19+
# Run a single test file
20+
uv run pytest tests/test__decorator.py
21+
22+
# Type checking
23+
uv run mypy cachium
24+
25+
# Run coverage
26+
uv run coverage run -m pytest && uv run coverage report
27+
28+
# Lint and format manually (pre-commit also runs these)
29+
uv run ruff check --fix cachium tests
30+
uv run ruff format cachium tests
31+
```
32+
33+
## Commit messages
34+
35+
This project uses [Conventional Commits](https://www.conventionalcommits.org/). The `commit-msg` pre-commit hook enforces this automatically.
36+
37+
Format: `<type>(<optional scope>): <description>`
38+
39+
Allowed types: `build`, `chore`, `ci`, `docs`, `feat`, `fix`, `perf`, `refactor`, `revert`, `style`, `test`
40+
41+
Examples:
42+
```
43+
feat: add Redis storage backend
44+
fix: prevent dog-pile under high concurrency
45+
docs: add CacheWith usage example
46+
chore: bump ruff to v0.16
47+
```
48+
49+
Breaking changes: append `!` after the type or add `BREAKING CHANGE:` in the footer.
50+
51+
## Pre-commit hooks
52+
53+
The following hooks run on every commit:
54+
55+
| Hook | Purpose |
56+
|------|---------|
57+
| `check-added-large-files` | Prevent accidental large file commits |
58+
| `check-json`, `check-yaml`, `check-toml` | Validate config files |
59+
| `check-merge-conflict` | Catch unresolved merge conflict markers |
60+
| `detect-private-key` | Block accidental secret commits |
61+
| `end-of-file-fixer`, `trailing-whitespace` | Normalize whitespace |
62+
| `no-commit-to-branch` | Block direct commits to `master` |
63+
| `add-trailing-comma` | Enforce trailing commas |
64+
| `ruff` | Lint and auto-fix Python code (includes import sorting) |
65+
| `ruff-format` | Format Python code |
66+
| `toml-sort` | Keep `pyproject.toml` keys sorted |
67+
| `conventional-pre-commit` | Enforce conventional commit message format (commit-msg stage) |
68+
69+
## Pull requests
70+
71+
- Direct pushes to `master` are blocked; open a PR instead.
72+
- PRs should be small and focused. One logical change per PR.
73+
- All CI checks (tests, type checking, pre-commit) must pass before merging.
74+
75+
## Extending the library
76+
77+
See [CLAUDE.md](CLAUDE.md) / [AGENTS.md](AGENTS.md) for the architecture overview and guidance on adding new storage backends, serializers, and key builders.

cachium/storages/ttl_map.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def __init__(self) -> None:
4343
def register_lock(self, key: TCacheKey, id_: int, timeout: float | None) -> None:
4444
deadline = time.monotonic() + timeout if timeout is not None else None
4545
with self._condition:
46-
4746
while key in self._locks:
4847
logger.debug("Key '%s' is in use, waiting for release.", key)
4948
wait_time = deadline - time.monotonic() if deadline is not None else None
@@ -71,7 +70,6 @@ def __init__(self) -> None:
7170

7271
async def register_lock(self, key: TCacheKey, id_: int, timeout: float | None) -> None:
7372
async with self._condition:
74-
7573
while key in self._locks:
7674
logger.debug("Key '%s' is in use, waiting for release.", key)
7775
try:

pyproject.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@ omit = [
7575
[tool.hatch.version]
7676
source = "uv-dynamic-versioning"
7777

78-
[tool.isort]
79-
float_to_top = true
80-
include_trailing_comma = true
81-
line_length = 120
82-
multi_line_output = 3
83-
use_parentheses = true
84-
8578
[tool.mypy]
8679
strict = true
8780

@@ -117,6 +110,7 @@ fixable = ["ALL"]
117110
ignore = [
118111
"A003", # Class attribute {name} is shadowing a python builtin
119112
"AIR", # airflow
113+
"COM812", # conflicts with ruff-format trailing comma management
120114
"CPY", # flake8-copyright
121115
"D100", # Missing docstring in public module
122116
"D104", # Missing docstring in public package

tests/test__ttl_map_storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def test_ttl_map_storage_max_size(max_size: int, keys_to_add: list[str], expecte
284284

285285
# Add all the keys
286286
for i, key in enumerate(keys_to_add):
287-
storage.set(key, f"value{i+1}")
287+
storage.set(key, f"value{i + 1}")
288288

289289
# Count the number of keys that are still in the cache
290290
keys_in_cache = 0

0 commit comments

Comments
 (0)