Skip to content

Commit 8168ff7

Browse files
authored
Merge pull request #1 from taskiq-python/feature/pre-commit
2 parents 320c3d4 + 8ccee4a commit 8168ff7

File tree

13 files changed

+147
-48
lines changed

13 files changed

+147
-48
lines changed
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
# This file is autogenerated by maturin v1.12.6
2-
# To update, run
3-
#
4-
# maturin generate-ci github
5-
#
6-
name: CI
1+
name: Release workflow
72

83
on:
94
release:
@@ -37,7 +32,7 @@ jobs:
3732
python-version: 3.x
3833
- name: Setting correct version
3934
run: |
40-
python scripts/bump_version.py "${{ github.ref_name }}"
35+
python scripts/bump_version.py "${{ github.ref_name }}"
4136
- name: Build wheels
4237
uses: PyO3/maturin-action@v1
4338
with:
@@ -73,7 +68,7 @@ jobs:
7368
python-version: 3.x
7469
- name: Setting correct version
7570
run: |
76-
python scripts/bump_version.py "${{ github.ref_name }}"
71+
python scripts/bump_version.py "${{ github.ref_name }}"
7772
- name: Build wheels
7873
uses: PyO3/maturin-action@v1
7974
with:
@@ -112,7 +107,7 @@ jobs:
112107
architecture: ${{ matrix.platform.python_arch }}
113108
- name: Setting correct version
114109
run: |
115-
python scripts/bump_version.py "${{ github.ref_name }}"
110+
python scripts/bump_version.py "${{ github.ref_name }}"
116111
- name: Build wheels
117112
uses: PyO3/maturin-action@v1
118113
with:
@@ -141,7 +136,7 @@ jobs:
141136
python-version: 3.x
142137
- name: Setting correct version
143138
run: |
144-
python scripts/bump_version.py "${{ github.ref_name }}"
139+
python scripts/bump_version.py "${{ github.ref_name }}"
145140
- name: Build wheels
146141
uses: PyO3/maturin-action@v1
147142
with:
@@ -163,7 +158,7 @@ jobs:
163158
python-version: 3.x
164159
- name: Setting correct version
165160
run: |
166-
python scripts/bump_version.py "${{ github.ref_name }}"
161+
python scripts/bump_version.py "${{ github.ref_name }}"
167162
- name: Build sdist
168163
uses: PyO3/maturin-action@v1
169164
with:

.github/workflows/test.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: "Testing package"
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
py-lint:
8+
strategy:
9+
matrix:
10+
cmd:
11+
- black
12+
- ruff
13+
- mypy
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: "3.11"
21+
- name: Run lint check
22+
uses: pre-commit/action@v3.0.0
23+
with:
24+
extra_args: -a ${{ matrix.cmd }}
25+
fmt:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v1
29+
- uses: actions-rs/toolchain@v1
30+
with:
31+
toolchain: stable
32+
components: rustfmt
33+
override: true
34+
- name: Check code format
35+
run: cargo fmt -- --check
36+
37+
clippy:
38+
permissions:
39+
checks: write
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v1
43+
- uses: actions-rs/toolchain@v1
44+
with:
45+
toolchain: stable
46+
components: clippy
47+
override: true
48+
- uses: auguwu/clippy-action@1.4.0
49+
with:
50+
token: ${{secrets.GITHUB_TOKEN}}
51+
deny: warnings

.pre-commit-config.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- repo: https://github.com/psf/black
7+
rev: 26.3.0
8+
hooks:
9+
- id: black
10+
name: python black
11+
pass_filenames: false
12+
always_run: true
13+
args: ["python"]
14+
- repo: https://github.com/pre-commit/mirrors-mypy
15+
rev: v1.19.1
16+
hooks:
17+
- id: mypy
18+
name: python mypy
19+
always_run: true
20+
pass_filenames: false
21+
args: ["python"]
22+
- repo: https://github.com/astral-sh/ruff-pre-commit
23+
rev: v0.15.5
24+
hooks:
25+
- id: ruff
26+
name: ruff
27+
pass_filenames: false
28+
always_run: true
29+
args: ["python", "--fix"]
30+
- repo: local
31+
hooks:
32+
- id: fmt
33+
types:
34+
- rust
35+
name: rust fmt
36+
language: system
37+
entry: cargo
38+
pass_filenames: false
39+
args:
40+
- fmt
41+
42+
- id: clippy
43+
types:
44+
- rust
45+
name: rust clippy
46+
language: system
47+
pass_filenames: false
48+
entry: cargo
49+
args:
50+
- clippy
51+
- --fix
52+
- --allow-dirty
53+
54+
- id: check
55+
types:
56+
- rust
57+
name: rust cargo check
58+
language: system
59+
entry: cargo
60+
pass_filenames: false
61+
args:
62+
- check

.rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use_try_shorthand=true

python/natsrpy/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
from natsrpy._inner import (
2-
Nats,
3-
Subscription,
4-
Message,
5-
)
1+
from natsrpy._inner import Message, Nats, Subscription
62

73
__all__ = [
84
"Nats",

python/natsrpy/_inner/js/kv.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from natsrpy._inner.js.stream import StorageType, Source, Placement, Republish
1+
from natsrpy._inner.js.stream import Placement, Republish, Source, StorageType
22

33
class KVConfig:
44
"""

python/natsrpy/js/kv.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from natsrpy._inner.js.kv import (
2-
KVConfig,
3-
KeyValue,
4-
)
1+
from natsrpy._inner.js.kv import KeyValue, KVConfig
52

63
__all__ = [
74
"KVConfig",

python/natsrpy/js/stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from natsrpy._inner.js.stream import (
22
External,
3+
Placement,
34
Republish,
45
Source,
56
StorageType,
67
SubjectTransform,
7-
Placement,
88
)
99

1010
__all__ = [

src/exceptions/py_err.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use pyo3::create_exception;
2-
use pyo3::pymodule;
1+
use pyo3::{create_exception, pymodule};
32

43
create_exception!(
54
natsrpy.exceptions,

src/js/jetstream.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
use std::ops::Deref;
2-
use std::sync::Arc;
1+
use std::{ops::Deref, sync::Arc};
32

4-
use async_nats::Subject;
5-
use async_nats::client::traits::Publisher;
6-
use async_nats::connection::State;
7-
use pyo3::types::{PyBytesMethods, PyDict};
8-
use pyo3::{Bound, PyAny, Python, pyclass, pymethods, types::PyBytes};
3+
use async_nats::{Subject, client::traits::Publisher, connection::State};
4+
use pyo3::{
5+
Bound, PyAny, Python, pyclass, pymethods,
6+
types::{PyBytes, PyBytesMethods, PyDict},
7+
};
98
use tokio::sync::RwLock;
109

11-
use crate::exceptions::rust_err::NatsrpyError;
12-
use crate::js::kv::{KVConfig, KeyValue};
13-
use crate::utils::headers::NatsrpyHeadermapExt;
14-
use crate::{exceptions::rust_err::NatsrpyResult, utils::natsrpy_future};
10+
use crate::{
11+
exceptions::rust_err::{NatsrpyError, NatsrpyResult},
12+
js::kv::{KVConfig, KeyValue},
13+
utils::{headers::NatsrpyHeadermapExt, natsrpy_future},
14+
};
1515

1616
#[pyclass]
1717
pub struct JetStream {

0 commit comments

Comments
 (0)