File: lint-code.py

package info (click to toggle)
python-graphviz 0.20.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,188 kB
  • sloc: python: 4,098; makefile: 13
file content (30 lines) | stat: -rw-r--r-- 712 bytes parent folder | download | duplicates (2)
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
27
28
29
30
#!/usr/bin/env python3

"""Run code linting with https://flake8.pycqa.org."""

import pathlib
import platform
import subprocess
import sys

SELF = pathlib.Path(__file__)

PYTHON = 'py' if platform.system() == 'Windows' else 'python'

CMD = [PYTHON, '-m', 'flake8']


print('run', [SELF.name] + sys.argv[1:])
cmd = CMD + sys.argv[1:]

print(f'subprocess.run({cmd!r})')
try:
    proc = subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
    assert e.returncode != 0, f'non-zero returncode: {e}'
    print('FAILED:', e)
    sys.exit(e.returncode)
else:
    assert proc.returncode == 0, f'passed: {proc}'
    print('PASSED:', proc)
    sys.exit(proc.returncode)