annotate tasks.py @ 1864:375f48d1518a

mypy, flake8 setups Ignore-this: 159ab09780ff33dec508d2d25c1628bf
author Drew Perttula <drewp@bigasterisk.com>
date Sat, 25 May 2019 12:03:26 +0000
parents
children f001d689b3e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1864
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
1 from invoke import task
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
2 import glob
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
3
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
4 bin_sources = [
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
5 'bin/ascoltami2',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
6 'bin/captureDevice',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
7 'bin/collector',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
8 'bin/collector_loadtest.py',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
9 'bin/effecteval',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
10 'bin/effectsequencer',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
11 'bin/homepageConfig',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
12 'bin/inputdemo',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
13 'bin/inputquneo',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
14 'bin/keyboardcomposer',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
15 'bin/listsongs',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
16 'bin/musicPad',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
17 'bin/musictime',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
18 'bin/paintserver',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
19 'bin/picamserve',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
20 'bin/rdfdb',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
21 'bin/run_local.py',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
22 'bin/subcomposer',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
23 'bin/subserver',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
24 'bin/vidref',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
25 'bin/vidrefsetup',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
26 'bin/wavecurve',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
27 ]
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
28 def pkg_sources():
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
29 return glob.glob('light9/**/*.py', recursive=True)
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
30
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
31 @task
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
32 def mypy(ctx):
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
33 def run(sources):
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
34 ss = ' '.join(sources)
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
35 ctx.run(f'MYPYPATH=stubs env/bin/mypy --check-untyped-defs {ss}',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
36 pty=True, warn=True)
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
37
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
38 sources = ' '.join(bin_sources + pkg_sources())
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
39 ctx.run(f'env/bin/flake8 --ignore=E115,E123,E124,E126,E225,E231,E261,E262,E265,E301,E302,E303,E305,E306,E401,E402,E501,E701,E731,W291,W293,W391,W504 {sources}', warn=True)
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
40
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
41 sources = ' '.join(pkg_sources())
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
42 for src in bin_sources:
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
43 print(f"mypy {src}")
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
44 run([src])# + pkg_sources())
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
45 @task
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
46 def reformat(ctx):
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
47 ctx.run("env/bin/yapf --verbose --parallel --in-place --style google light9/**/*.py `file --no-pad bin/* | grep 'Python script' | perl -lpe 's/:.*//'`")
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
48
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
49 @task
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
50 def test(ctx):
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
51 ctx.run('docker build -f Dockerfile.build -t light9_build:latest .')
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
52 ctx.run('docker run --rm -it -v `pwd`:/opt light9_build:latest'
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
53 ' nose2 -v light9.currentstategraphapi_test light9.graphfile_test',
375f48d1518a mypy, flake8 setups
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
54 pty=True)