Skip to content

Commit b48518a

Browse files
committed
chore: more linters and pre-commit hooks
1 parent c870142 commit b48518a

File tree

7 files changed

+108
-17
lines changed

7 files changed

+108
-17
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "monthly"
7+
cooldown:
8+
default-days: 30
79
- package-ecosystem: "github-actions"
810
directory: "/"
911
schedule:
1012
interval: "monthly"
13+
cooldown:
14+
default-days: 30

.github/workflows/code-check.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
pull_request:
66
branches: [ main ]
77

8+
permissions:
9+
actions: read
10+
contents: read
11+
pull-requests: read
12+
813
jobs:
914
test:
1015
name: Tests
@@ -28,9 +33,11 @@ jobs:
2833
ports:
2934
- 5432:5432
3035
steps:
31-
- uses: actions/checkout@v5
36+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
37+
with:
38+
persist-credentials: false
3239
- id: setup-uv
33-
uses: astral-sh/setup-uv@v7
40+
uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
3441
with:
3542
enable-cache: true
3643
cache-suffix: ${{ matrix.python-version }}

.github/workflows/release_docs.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,24 @@ jobs:
2121
steps:
2222
- name: Checkout merge commit (auto on merge to main)
2323
if: ${{ github.event_name == 'pull_request' }}
24-
uses: actions/checkout@v5
24+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2525
with:
2626
ref: ${{ github.event.pull_request.merge_commit_sha }}
27+
persist-credentials: false
2728

2829
- name: Checkout PR merge ref (manual on PR)
2930
if: ${{ github.event_name == 'workflow_dispatch' }}
30-
uses: actions/checkout@v5
31+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3132
with:
3233
ref: refs/pull/${{ inputs.pr }}/merge
34+
persist-credentials: false
3335

3436
- name: Configure Git Credentials
3537
run: |
3638
git config user.name github-actions[bot]
3739
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
3840
39-
- uses: astral-sh/setup-uv@v7
41+
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
4042
with:
4143
enable-cache: true
4244
python-version: "3.12"

.github/workflows/release_pypi.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ jobs:
1515
permissions:
1616
id-token: write
1717
steps:
18-
- uses: actions/checkout@v5
19-
- uses: astral-sh/setup-uv@v7
18+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2019
with:
21-
enable-cache: true
20+
persist-credentials: false
21+
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
22+
with:
23+
enable-cache: false
2224
python-version: "3.12"
2325
version: "latest"
24-
- run: uv version "${{ github.ref_name }}"
26+
- run: uv version "${GITHUB_REF_NAME}"
2527
- run: uv build
2628
- run: uv publish --trusted-publishing always

.pre-commit-config.yaml

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,73 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
13
repos:
2-
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.14.0
4+
- repo: https://github.com/compilerla/conventional-pre-commit
5+
rev: v4.3.0
46
hooks:
5-
- id: ruff-check
6-
args: [--fix]
7-
- id: ruff-format
7+
- id: conventional-pre-commit
8+
stages: [commit-msg]
9+
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v6.0.0
12+
hooks:
13+
- id: trailing-whitespace
14+
- id: mixed-line-ending
15+
- id: check-case-conflict
16+
- id: check-ast
17+
- id: check-toml
18+
- id: check-yaml
19+
- id: check-added-large-files
20+
- id: end-of-file-fixer
21+
22+
- repo: https://github.com/crate-ci/typos
23+
rev: v1.38.1
24+
hooks:
25+
- id: typos
26+
27+
- repo: https://github.com/Yelp/detect-secrets
28+
rev: v1.5.0
29+
hooks:
30+
- id: detect-secrets
31+
args: [
32+
'--exclude-lines', 'look_in_vault',
33+
'--exclude-lines', 'taskiq_postgres',
34+
'--exclude-lines', 'postgresql://postgres:postgres@localhost:5432/postgres',
35+
]
36+
37+
- repo: local
38+
hooks:
39+
- id: ruff
40+
name: Ruff
41+
entry: make ruff
42+
language: python
43+
types: [python]
44+
require_serial: true
45+
verbose: true
46+
pass_filenames: false
47+
48+
- id: mypy
49+
name: Mypy
50+
entry: make mypy
51+
language: python
52+
types: [python]
53+
require_serial: true
54+
verbose: true
55+
pass_filenames: false
56+
57+
- id: bandit
58+
name: bandit
59+
entry: uv run --active --frozen bandit -c pyproject.toml -r src
60+
language: python
61+
types: [python]
62+
require_serial: true
63+
verbose: true
64+
pass_filenames: false
65+
66+
- id: zizmor
67+
name: zizmor
68+
language: python
69+
entry: uv run --active --frozen zizmor .
70+
files: ^\.github
71+
require_serial: true
72+
verbose: true
73+
pass_filenames: false

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
args := $(wordlist 2, 100, $(MAKECMDGOALS))
22

3+
VIRTUAL_ENV=.venv
4+
35
.DEFAULT:
46
@echo "No such command (or you pass two or many targets to ). List of possible commands: make help"
57

@@ -35,8 +37,16 @@ run_infra: ## Run rabbitmq in docker for integration tests
3537

3638
.PHONY: lint
3739
lint: ## Run linting
38-
@uv run ruff check src tests
39-
@uv run mypy src
40+
@$(MAKE) ruff
41+
@$(MAKE) mypy
42+
43+
.PHONY: ruff
44+
ruff: ## Run ruff linting
45+
@uv run --active --frozen ruff check src tests
46+
47+
.PHONY: mypy
48+
mypy: ## Run mypy type checking
49+
@uv run --active --frozen mypy src
4050

4151
.PHONY: format
4252
format: ## Run formatting

docs/tutorial/common_issues.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Common Issues
77
Ensure your connection string is correct:
88

99
```python
10-
dsn = "postgresql://username:password@host:port/database"
10+
dsn = "postgresql://postgres:postgres@localhost:5432/postgres"
1111
```
1212

1313
Check PostgreSQL is running and accessible:

0 commit comments

Comments
 (0)