probcomp/bayeslite

Flake8: F821 undefined name 'PLUS'

cclauss opened this issue · 4 comments

Flake8 testing of https://github.com/probcomp/bayeslite on Python 2.7.13

$ flake8 . --count --select=E901,E999,F821,F822,F823 --statistics

./external/lemonade/dist/examples/calc/calc.py:25:10: F821 undefined name 'PLUS'
./external/lemonade/dist/examples/calc/calc.py:26:10: F821 undefined name 'MINUS'
./external/lemonade/dist/examples/calc/calc.py:27:10: F821 undefined name 'DIVIDE'
./external/lemonade/dist/examples/calc/calc.py:28:10: F821 undefined name 'TIMES'
./external/lemonade/dist/examples/calc/calc.py:39:20: F821 undefined name 'NUM'
./external/lemonade/dist/examples/calc/calc.py:79:5: F821 undefined name 'Parser'

./external/plex/dist/Plex/Regexps.py:125:9: F821 undefined name 'exceptions'

./src/compiler.py:1085:24: F821 undefined name 'bdb'
./src/compiler.py:1103:24: F821 undefined name 'bdb'
./src/compiler.py:1158:24: F821 undefined name 'bdb'
./src/compiler.py:1276:24: F821 undefined name 'bdb'
./src/compiler.py:1340:24: F821 undefined name 'bdb'
./src/compiler.py:1456:24: F821 undefined name 'bdb'

./src/simulate.py:68:40: F821 undefined name 'v'
fsaad commented

The bayeslite test suite uses pytest and not flake8 for testing. The main README page shows how to correctly invoke the test suite using the ./check.sh script at the root of the project.

https://en.wikipedia.org/wiki/Defense_in_depth_(computing) There is nothing wrong with having multiple lines of defense given that the current pytest testing is unable to spot Python syntax errors.

    # stop the build if there are Python syntax errors or undefined names
    - flake8 . --count --select=E901,E999,F821,F822,F823 --statistics
    # exit-zero treats all errors as warnings.  The GitHub editor is 127 chars wide
    - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
fsaad commented

@cclauss Ah, I misunderstood the bug report. Thank you for notifying us about the syntax errors. I thought you were trying to run the test suite but could not because flake8 was reporting these errors.

@riastradh-probcomp Here are some notes on the syntax issues that @cclauss reported:

  1. The following are from the ./external packages, which I believe we do not maintain. Is it worth addressing these?
./external/lemonade/dist/examples/calc/calc.py:25:10: F821 undefined name 'PLUS'
./external/lemonade/dist/examples/calc/calc.py:26:10: F821 undefined name 'MINUS'
./external/lemonade/dist/examples/calc/calc.py:27:10: F821 undefined name 'DIVIDE'
./external/lemonade/dist/examples/calc/calc.py:28:10: F821 undefined name 'TIMES'
./external/lemonade/dist/examples/calc/calc.py:39:20: F821 undefined name 'NUM'
./external/lemonade/dist/examples/calc/calc.py:79:5: F821 undefined name 'Parser'

./external/plex/dist/Plex/Regexps.py:125:9: F821 undefined name 'exceptions'
  1. This batch are documented in #563: Missing bdb argument in implicit_reference_var_colno_exp in compiler.py will cause RuntimeError.
./src/compiler.py:1085:24: F821 undefined name 'bdb'
./src/compiler.py:1103:24: F821 undefined name 'bdb'
./src/compiler.py:1158:24: F821 undefined name 'bdb'
./src/compiler.py:1276:24: F821 undefined name 'bdb'
./src/compiler.py:1340:24: F821 undefined name 'bdb'
./src/compiler.py:1456:24: F821 undefined name 'bdb'
  1. The following syntax error is wrapped in an if False block, so is effectively never run. The XXX on line 59 contains some explanation for why this code even exists, we should probably just remove the entire code block.
./src/simulate.py:68:40: F821 undefined name 'v'

Should be fixed by 248beea and 248beea. @fsaad is correct that the code under external is not relevant here (also, it turns out not to be broken in the way flake8 expects -- rather, the lemonade example uses exec at the top level, which is a different kind of moral brokenness that nevertheless functions in practice).