Skip to content

Commit 5bc8d1e

Browse files
committed
feat: add inv format command
1 parent fd80113 commit 5bc8d1e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ source venv/bin/activate
8484
pip install -r requirements.lint.txt
8585
# Run lint
8686
inv lint
87+
# Run formatter (will tell you which files it modified)
88+
inv format
8789
```
8890

8991
If you get the error `ERROR:darker.git:fatal: Not a valid commit name <hash>`,

tasks.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,19 @@ def _migrate_file(url: str, filename: str):
3434
def lint(c, revision="origin/dev"):
3535
"""Lint and format.
3636
37-
Additional linter settings can be found in `pyproject.toml` (`darker` will
38-
use those settings as well).
37+
Linter/formatter are automatically read from `pyproject.toml`.
3938
"""
4039
c.run(f"darker --diff --check --revision {revision} .", warn=True)
4140
c.run("echo '\n'")
4241
out = c.run(f"git diff -U0 {revision} | lint-diffs")
4342
if out.stdout.strip() != "=== pylint: mine=0, always=0":
4443
print(out.stdout)
44+
45+
46+
@task
47+
def format(c, revision="origin/dev"):
48+
"""Format code.
49+
50+
Linter/formatter are automatically read from `pyproject.toml`.
51+
"""
52+
c.run(f"darker --verbose --revision {revision} .", warn=True)

0 commit comments

Comments
 (0)