Skip to content

Commit e43dc3d

Browse files
committed
Setup toml formatting with taplo
In the Justfile, this is run via `uvx` to avoid adding a build dependency
1 parent f32d0b1 commit e43dc3d

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

.taplo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[formatting]
2+
indent_string = " "
3+
array_auto_collapse = false
4+
column_width = 120
5+
# this tries to line up comments after entries in a nice little table
6+
# these sorts of ASCII tables are far too fragile for my taste
7+
align_comments = false

Justfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ fix-spelling:
5454
# Fix obvious spelling issues
5555
typos --write-changes
5656

57+
# taplo logging is excessively verbose (prints 'file detection' but not files changed)
58+
export RUST_LOG := "taplo=warn"
59+
5760
# Checks for formatting issues
5861
check-format: && spellcheck
5962
@# Invoking ruff directly instead of through uv tool run saves ~12ms per command,
@@ -63,9 +66,13 @@ check-format: && spellcheck
6366
@# project dependencies, which can add an additional 100+ ms
6467
ruff format --check .
6568
ruff check --select I --output-format concise .
69+
# check toml formatting
70+
uvx taplo format --check
6671

6772
format: _format && spellcheck
6873

6974
_format:
7075
ruff format .
7176
ruff check --select 'I' --fix .
77+
# format toml
78+
uvx taplo format

_typos.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[files]
2-
ignore-hidden = false # we want dotfiles
2+
ignore-hidden = false # we want dotfiles
33
extend-exclude = [
44
".git", # needed because we 'ignore-hidden'
55
]

lefthook.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ pre-commit:
1616
tags: formatter
1717
glob: "*.{py,pyi}"
1818
run: ruff check --select 'I' --output-format 'concise' -- {staged_files}
19+
taplo:
20+
tags: formatter
21+
glob: "*.toml"
22+
# No need to --force-exclude for taplo
23+
run: taplo format --check -- {staged_files}
24+
env:
25+
# without this, taplo is very verbose
26+
RUST_LOG: warn
1927
typos:
2028
tags: spellcheck
2129
run: typos --force-exclude -- {staged_files}

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ pydantic = [
2323
]
2424

2525
[dependency-groups]
26-
mypy = ["mypy~=1.0", {include-group = "typing"}]
26+
mypy = ["mypy~=1.0", { include-group = "typing" }]
2727
test = [
2828
"pytest~=8.3",
2929
"pytest-asyncio>=0.26",
3030
"pytest-sugar~=1.0",
31-
"techcable.orderedset[pydantic]"
31+
"techcable.orderedset[pydantic]",
3232
]
3333
typing = ["typing-extensions~=4.12", "techcable.orderedset[pydantic]"]
34-
dev = [{include-group = "mypy"}, {include-group = "test"}]
34+
dev = [{ include-group = "mypy" }, { include-group = "test" }]
3535

3636
[project.urls]
3737
Source = "https://github.com/Techcable/orderedset.py"

0 commit comments

Comments
 (0)