You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migen / LiteX doesn't quite follow pep8 / pylint for good reasons. Extend pep8 and/or pylint to understand when it should allow violations. Extra additional checks for good Migen / LiteX style should also be added.
Expected results
Running pep8-migen on Migen / LiteX HDL code does the following;
Checks all Python code that isn't Migen / LiteX complies with pep8 standard
Checks Migen / LiteX code compiles with the standard formatting style for Migen / LiteX
Checks for more common Migen / LiteX code smells.
Detailed Explanation
Due to the way the MiSoC / LiteX code works, this is preferred way to format the following statement;
When the code is formatting this way it will fail pep8 with the following output;
$ pep8 misoc.py
misoc.py:6:9: E124 closing bracket does not match visual indentation
misoc.py:7:13: E128 continuation line under-indented for visual indent
misoc.py:8:9: E124 closing bracket does not match visual indentation
We need a pep8 / pylint extension which understand MiSoC / LiteX HDL formatting.
There are also a number of LiteX / Migen "code smells" that pep8 / pylint should also detect. Some are listed in the following section.
Migen / LiteX code smells
pep8 code smells which definitely apply
Using a bare try/except: clause
Pretty much most things
FIXME: Put more things here
pep8 code smells which do not apply
Wrapping of statements in pep8 style inside comb / sync blocks.
FIXME: Put more things here.
Incorrect wrapping of final brace
All lists / dictionaries should have commas on the last element;
The main contributors of migen/misoc are not using the following rules:
Missing Comma on final element in list / dictionary
Using line continuation rather than list
I see why you want that (to ease future changes in the code), but this should be an advice and probably not a rule. Some can found code easier to read without this so would avoid comma where not really needed or allow use of line continuation when only one element is in the comb/sync statement.
mithro
changed the title
Add support to pep8 / pylint for the "MiSoC / LiteX" formatting style & new specific checks
[LiteX] Add support to pep8 / pylint for the "MiSoC / LiteX" formatting style & new specific checks
Feb 12, 2018
Brief explanation
Migen / LiteX doesn't quite follow pep8 / pylint for good reasons. Extend pep8 and/or pylint to understand when it should allow violations. Extra additional checks for good Migen / LiteX style should also be added.
Expected results
Running
pep8-migen
on Migen / LiteX HDL code does the following;Detailed Explanation
Due to the way the MiSoC / LiteX code works, this is preferred way to format the following statement;
See the migen documentation for more examples.
When the code is formatting this way it will fail
pep8
with the following output;We need a pep8 / pylint extension which understand MiSoC / LiteX HDL formatting.
There are also a number of LiteX / Migen "code smells" that pep8 / pylint should also detect. Some are listed in the following section.
Migen / LiteX code smells
pep8 code smells which definitely apply
try
/except:
clausepep8 code smells which do not apply
comb
/sync
blocks.Incorrect wrapping of final brace
All lists / dictionaries should have commas on the last element;
No;
Yes;
Missing Comma on final element in list / dictionary
All lists / dictionaries should have commas on the last element;
No;
Yes;
No;
Yes;
Using line continuation rather than list
FIXME: Check this one makes sense...
No;
Yes;
Using the wrong docstring style
Migen / LiteX use the "Numpy DocString style" for docstring comments.
See examples;
Code should not be using the "Google DocString Style" and not the "PEP 287 DocString Style"
This is supported by the napoleon module in Sphinx.
Not using
yield from
in test bencheshttps://m-labs.hk/migen/manual/simulation.html#pitfalls
Further reading
Knowledge Prerequisites
Contacts
The text was updated successfully, but these errors were encountered: