microsoft / knossos-ksc

Compiler with automatic differentiation
Other
45 stars 10 forks source link

Enable flake8 to stop build #985

Closed cgravill closed 3 years ago

cgravill commented 3 years ago

We had flake8 configured informationally to not stop builds (--exit-zero) but based on a lot of clean-ups - thanks to various folks - we can now turn on enforcement.

Few more linting fixes, possibly dead code in tests.

Motivated by: https://github.com/microsoft/knossos-ksc/pull/983#pullrequestreview-716724059

Longer term switching to pylint is still an option but efforts on that are stalled in RLO https://github.com/awf/knossos/pull/1544 and we'd need to go over potentially legitimate issues in KSC first.

cgravill commented 3 years ago

Just as a note, I'd be keen to upgrade to F8 warnings in the future, these are the current violations:

.\examples\dl-activations\relu3.py:592:5: F841 local variable 'model' is assigned to but never used
    model = nn.Sequential(
    ^
.\src\bench\run-bench.py:113:13: F841 local variable 'pt_nice' is assigned to but never used
            pt_nice = fn_obj
            ^
.\src\onnx2ks\onnx-build-prelude.py:59:1: F811 redefinition of unused 'warnings' from line 38
import warnings
^
.\src\onnx2ks\onnx-build-prelude.py:270:9: F841 local variable 'output_typeStrs' is assigned to but never used
        output_typeStrs = set([o.typeStr for o in s.outputs])
        ^
.\src\onnx2ks\onnx2ks.py:48:1: F811 redefinition of unused 'warnings' from line 21
import warnings
^
.\src\onnx2ks\onnx2ks.py:204:5: F841 local variable '_nbytes' is assigned to but never used
    _nbytes = val.ParseFromString(attr._default_value)
    ^
.\test\python\test_structured_names.py:7:1: F811 redefinition of unused 'Type' from line 3
from ksc.type import Type
^
.\test\ts2k\test0.py:12:5: F841 local variable 't2' is assigned to but never used
    t2 = f(t)
    ^
.\test\ts2k\test_torch_frontend.py:30:9: F841 local variable 'dtdx' is assigned to but never used
        dtdx = x
        ^

https://flake8.pycqa.org/en/3.9.2/user/error-codes.html?highlight=codes#error-violation-codes