spacify 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spacify-0.1.0/CHANGELOG.md +8 -0
- spacify-0.1.0/CONTRIBUTING.md +95 -0
- spacify-0.1.0/Cargo.lock +687 -0
- spacify-0.1.0/Cargo.toml +52 -0
- spacify-0.1.0/LICENSE +21 -0
- spacify-0.1.0/PKG-INFO +154 -0
- spacify-0.1.0/README.md +135 -0
- spacify-0.1.0/SECURITY.md +23 -0
- spacify-0.1.0/pyproject.toml +41 -0
- spacify-0.1.0/rust-toolchain.toml +5 -0
- spacify-0.1.0/rustfmt.toml +2 -0
- spacify-0.1.0/src/config.rs +139 -0
- spacify-0.1.0/src/edit.rs +39 -0
- spacify-0.1.0/src/lib.rs +9 -0
- spacify-0.1.0/src/main.rs +196 -0
- spacify-0.1.0/src/python/mod.rs +284 -0
- spacify-0.1.0/src/python/rules.rs +77 -0
- spacify-0.1.0/src/walk.rs +81 -0
- spacify-0.1.0/tests/cli.rs +127 -0
- spacify-0.1.0/tests/fixtures.rs +98 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
You need a Rust toolchain (`rustup`; `rust-toolchain.toml` picks the channel and components), `make`,
|
|
6
|
+
[prek](https://github.com/j178/prek) and [uv](https://docs.astral.sh/uv/). The ruff round trip also
|
|
7
|
+
needs `ruff` on `PATH`, and `make build` needs `maturin`:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
uv tool install prek
|
|
11
|
+
uv tool install ruff
|
|
12
|
+
uv tool install maturin
|
|
13
|
+
make install
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`make install` installs the git hooks. To use the commit message template as well:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
git config commit.template .gitmessage
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## The gates
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
make check
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
runs everything CI runs except the security scan: format (rustfmt), lint (clippy, zizmor), the
|
|
29
|
+
tests, and the ruff round trip over the fixtures and CPython's `Lib`. `make help` lists the
|
|
30
|
+
individual targets. `make format` is the one that fixes, where `make check` only reports.
|
|
31
|
+
|
|
32
|
+
The git hooks run the same Rust checks, plus a few that only make sense there: secrets (gitleaks),
|
|
33
|
+
spelling (codespell), Markdown (markdownlint) and the workflow audits (actionlint, zizmor). `make
|
|
34
|
+
hooks` runs all of them over the whole tree.
|
|
35
|
+
|
|
36
|
+
## How the code is laid out
|
|
37
|
+
|
|
38
|
+
`src/python/mod.rs` parses with tree-sitter and turns each pair of sibling statements into a `Gap`.
|
|
39
|
+
`src/python/rules.rs` decides how many blank lines that gap should have, or that no rule has an
|
|
40
|
+
opinion. `src/edit.rs` rewrites only those blank-line runs, so a rule can never change a byte inside
|
|
41
|
+
a statement. `src/main.rs` and `src/walk.rs` are the command line and the file walk.
|
|
42
|
+
|
|
43
|
+
A rule must hold the promise in the README: it never moves a blank-line count outside what `ruff
|
|
44
|
+
format` keeps. Check `ruff format --isolated` on a sample before writing a rule, because ruff owns
|
|
45
|
+
more gaps than it looks like it does (those next to a `def` or a `class`, after an import, after a
|
|
46
|
+
docstring).
|
|
47
|
+
|
|
48
|
+
## Tests
|
|
49
|
+
|
|
50
|
+
A rule change comes with a fixture: `tests/fixtures/<name>.py` and the `<name>.expected.py` it must
|
|
51
|
+
format to. The test also checks that the expected file is a fixed point. To rewrite the expected
|
|
52
|
+
files from the current output, then review the diff:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
SPACIFY_BLESS=1 cargo test --test fixtures
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`make compat` is the check that matters for ruff: both orders, over the fixtures and CPython.
|
|
59
|
+
`make bench` times a check over CPython's `Lib` with hyperfine.
|
|
60
|
+
|
|
61
|
+
## Commits and pull requests
|
|
62
|
+
|
|
63
|
+
Commits follow [Conventional Commits](https://www.conventionalcommits.org):
|
|
64
|
+
`<type>(<scope>): Summary`, with the body saying why the change exists. `.gitmessage` has the
|
|
65
|
+
details.
|
|
66
|
+
|
|
67
|
+
Pull requests are squash-merged, so **the pull request title is the commit**. CI checks that it is
|
|
68
|
+
a conventional one.
|
|
69
|
+
|
|
70
|
+
- `feat` bumps the minor version and `fix` the patch.
|
|
71
|
+
- `feat!`, or a `BREAKING CHANGE:` footer, is a breaking change: a minor bump while the version is
|
|
72
|
+
below 1.0, a major one after. A rule that changes formatted output is a `feat`, since every user's
|
|
73
|
+
next run rewrites files.
|
|
74
|
+
- `docs`, `perf` and `revert` bump the patch too: they appear in the changelog, and whatever appears
|
|
75
|
+
there is released.
|
|
76
|
+
- Everything else (`chore`, `refactor`, `test`, `ci`, `build`, `style`) bumps nothing.
|
|
77
|
+
|
|
78
|
+
## Releases
|
|
79
|
+
|
|
80
|
+
Nobody edits a version. [Release Please](https://github.com/googleapis/release-please) reads the
|
|
81
|
+
commits on `main` and keeps a release pull request open with the next version (in `Cargo.toml` and
|
|
82
|
+
`Cargo.lock`) and the changelog. `pyproject.toml` reads the version from `Cargo.toml`.
|
|
83
|
+
|
|
84
|
+
Merging the release pull request tags the release, builds wheels for Linux (manylinux and musl,
|
|
85
|
+
x86_64 and aarch64), macOS (x86_64 and arm64) and Windows (x64), and publishes them to PyPI through
|
|
86
|
+
[trusted publishing](https://docs.pypi.org/trusted-publishers/). The publish job waits for a
|
|
87
|
+
maintainer to approve the `pypi` deployment.
|
|
88
|
+
|
|
89
|
+
Once PyPI has the version, the workflow pins it in
|
|
90
|
+
[spacify-pre-commit](https://github.com/avanserv/spacify-pre-commit) and tags that repository with
|
|
91
|
+
the same version. That is the repository users put in their hook configuration.
|
|
92
|
+
|
|
93
|
+
## Security
|
|
94
|
+
|
|
95
|
+
See [SECURITY.md](SECURITY.md).
|