File: format.py

package info (click to toggle)
python-rcssmin 1%3A1.1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,196 kB
  • sloc: python: 2,379; ansic: 1,216; sh: 110; makefile: 20
file content (26 lines) | stat: -rw-r--r-- 561 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- encoding: ascii -*-
"""
Running code formatters
~~~~~~~~~~~~~~~~~~~~~~~

"""

import invoke as _invoke


@_invoke.task(default=True)
def black(ctx, diff=False):
    """Format python code using Black formatter"""
    exe = ctx.shell.frompath('black')
    if exe is None:
        raise RuntimeError("black not found")

    with ctx.shell.root_dir():
        ctx.run(
            ctx.c(
                '%%s %s --config black.toml .'
                % ('--diff --color' if diff else '',),
                exe,
            ),
            echo=True,
        )