Add .flake8 config for rpython

Merged Oliver Margetts requested to merge branch/flake8-configs into branch/default

This adds two files: a top-level .flake8 for repo-wide usage, and a slightly tighter .flake8 to rpython/. The former file is slightly more permissive than the latter. After this commit it's possible to run flake8 and cd rpython && flake8 in a python 2 venv.

A pretty good start to any rpython3 effort would be to run cd rpython && flake8 from a python3 venv in CI. Currently that's not possible due to syntax errors.

For now I added lib-python to the flake8 exclude list.


Examples of things currently flagged as bad code by the rpython .flake8, but not the top-level .flake8:

a <> b
async = True
__all__ = ["not_here"]

A small before/after picture in an editor. Default flake8 config: image

with new file, actually useful for spotting mistakes: image


Still to do: Done:

  • add flake8 for other directories. There are a few questions to consider - e.g. lib-python we don't really control the stdlib code, so should we lint it?
  • fix a few actual errors that flake8 found for rpython (mostly harmless, some raise exceptions in py3):
./rlib/rsocket.py:467:20: F507 '...' % ... has 1 placeholder(s) but 2 substitution(s)
./rtyper/lltypesystem/opimpl.py:62:33: F507 '...' % ... has 2 placeholder(s) but 3 substitution(s)
./rtyper/lltypesystem/opimpl.py:65:33: F507 '...' % ... has 2 placeholder(s) but 3 substitution(s)
./jit/backend/zarch/instructions.py:105:5: F601 dictionary key 'OIHH' repeated with different values
./jit/backend/zarch/instructions.py:106:5: F601 dictionary key 'OIHL' repeated with different values
./jit/backend/zarch/instructions.py:107:5: F601 dictionary key 'OILH' repeated with different values
./jit/backend/zarch/instructions.py:108:5: F601 dictionary key 'OILL' repeated with different values
./jit/backend/zarch/instructions.py:121:5: F601 dictionary key 'OIHH' repeated with different values
./jit/backend/zarch/instructions.py:122:5: F601 dictionary key 'OIHL' repeated with different values
./jit/backend/zarch/instructions.py:123:5: F601 dictionary key 'OILH' repeated with different values
./jit/backend/zarch/instructions.py:124:5: F601 dictionary key 'OILL' repeated with different values
  • Work out if the following are false positives this occurs because they're manually set in globals():
./pypy/tool/stdlib_opcode.py:9:1: F822 undefined name 'opmap' in __all__
./pypy/tool/stdlib_opcode.py:9:1: F822 undefined name 'opname' in __all__
./pypy/tool/stdlib_opcode.py:9:1: F822 undefined name 'HAVE_ARGUMENT' in __all__
./pypy/tool/stdlib_opcode.py:9:1: F822 undefined name 'hasconst' in __all__
./pypy/tool/stdlib_opcode.py:9:1: F822 undefined name 'hasname' in __all__
./pypy/tool/stdlib_opcode.py:9:1: F822 undefined name 'hasjrel' in __all__
./pypy/tool/stdlib_opcode.py:9:1: F822 undefined name 'hasjabs' in __all__
./pypy/tool/stdlib_opcode.py:9:1: F822 undefined name 'haslocal' in __all__
./pypy/tool/stdlib_opcode.py:9:1: F822 undefined name 'hascompare' in __all__
./pypy/tool/stdlib_opcode.py:9:1: F822 undefined name 'hasfree' in __all__
./pypy/tool/stdlib_opcode.py:9:1: F822 undefined name 'cmp_op' in __all__
./lib_pypy/pyrepl/readline.py:38:1: F822 undefined name 'read_init_file' in __all__
./lib_pypy/pyrepl/readline.py:38:1: F822 undefined name 'redisplay' in __all__
./lib_pypy/pyrepl/readline.py:38:1: F822 undefined name 'set_pre_input_hook' in __all__
  • Possibly fix the following which look like genuine errors:
./pypy/module/thread/test/test_gil.py:86:51: F507 '...' % ... has 2 placeholder(s) but 3 substitution(s)
./pypy/doc/tool/makecontributor.py:46:5: F601 dictionary key 'Toon Verwaest' repeated with different values
./pypy/doc/tool/makecontributor.py:66:5: F601 dictionary key 'Roberto De Ioris' repeated with different values
./pypy/doc/tool/makecontributor.py:67:5: F601 dictionary key 'Roberto De Ioris' repeated with different values
./pypy/doc/tool/makecontributor.py:89:5: F601 dictionary key 'Toon Verwaest' repeated with different values
./pypy/tool/rest/rst.py:281:9: F901 'raise NotImplemented' should be 'raise NotImplementedError'
./pypy/tool/rest/rst.py:285:9: F901 'raise NotImplemented' should be 'raise NotImplementedError'
./pypy/tool/rest/rst.py:386:9: F901 'raise NotImplemented' should be 'raise NotImplementedError'

--HG-- branch : flake8-configs

Edited by Oliver Margetts

Merge request reports