Skip to content

docs(taplo): add toml formatter #1456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
- id: debug-statements
- id: no-commit-to-branch
- id: check-merge-conflict
- id: check-toml
- id: check-toml # TOML linter (syntax checker)
- id: check-yaml
args: [ '--unsafe' ] # for mkdocs.yml
- id: detect-private-key
Expand Down Expand Up @@ -55,17 +55,22 @@ repos:
stages:
- post-commit

- repo: https://github.com/ComPWA/taplo-pre-commit
rev: v0.9.3
hooks:
- id: taplo-format

- repo: local
hooks:
- id: format
name: Format
name: Format Python code via Poetry
language: system
pass_filenames: false
entry: poetry format
types: [ python ]

- id: linter and test
name: Linters
name: Linters via Poetry
language: system
pass_filenames: false
entry: poetry lint
Expand Down
4 changes: 4 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include = ["pyproject.toml", ".taplo.toml"]

[formatting]
indent_string = " "
5 changes: 5 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,10 @@ flowchart TD
review
```

## Install [taplo](https://taplo.tamasfe.dev/cli/installation/cargo.html) (toml formatter)

TODO: adjust this when the major documentation changes are merged



[conventional-commits]: https://www.conventionalcommits.org/
12 changes: 2 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,7 @@ cover.help = "Run the test suite with coverage"
cover.ref = "test --cov-report term-missing --cov-report=xml:coverage.xml --cov=commitizen"

all.help = "Run all tasks"
all.sequence = [
"format",
"lint",
"cover",
"check-commit",
]
all.sequence = ["format", "lint", "cover", "check-commit"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this one? But it seems to be a one-liner still

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find a good combination of options to keep the file unchanged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I set array_auto_collapse = false then someone with their formatter can still make it a one-liner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I set column_width = n for some n < 80 then taplo introduces more changes.


"doc:screenshots".help = "Render documentation screeenshots"
"doc:screenshots".script = "scripts.gen_cli_help_screenshots:gen_cli_help_screenshots"
Expand All @@ -267,10 +262,7 @@ doc.help = "Live documentation server"
doc.cmd = "mkdocs serve"

ci.help = "Run all tasks in CI"
ci.sequence = [
{ cmd = "pre-commit run --all-files" },
"cover",
]
ci.sequence = [{ cmd = "pre-commit run --all-files" }, "cover"]
ci.env = { SKIP = "no-commit-to-branch" }

setup-pre-commit.help = "Install pre-commit hooks"
Expand Down