Context: Before writing a test suite, it makes sense to first perform static analysis of the code, in order to catch any obvious bugs and deficiencies. This ensures that we begin writing functional tests from a higher level of quality. It also will allow us to better keep track of TODOs present in the source code.
Description of changes:
A .pylintrc config file is added to ensure some sensible defaults.
The qdata/ folder was linted, and any reported bugs fixed. This includes:
The insert_includes keyword argument was not correctly serializing the included files when set to True. This has been fixed; in addition, it was renamed to inline. This is inspired from C, where inline instructs the compiler to 'inline' any header definitions. Here, we use the term to instruct the serializer to 'inline' any included files.
The OpenQASM version was being set to 2.0 by default, even if not specified in the parsed file. This does not make sense; the IR should reflect the parsed file exactly. The default has been changed to None.
The Ops.RESET enum has been added to the IR, and used within the parser.
Redundant super() calls were removed.
Docstrings were added where missing.
Unused imports were removed.
In some cases, keyword arguments were being used incorrectly (e.g., kwargs before args, kwargs not being defined). This has been corrected.
Finally, while linting, future tasks/issues were noted via TODO comments.
Benefits:
Code is now slightly cleaner, which should help with new developer onboarding.
Minimal docstrings have been added, which should help with development/keeping track of relationships between methods.
Various bugs have been fixed.
It is now easier to keep track of TODOs, via pylint:
$ pylint qdata
************* Module qdata.ir
qdata/ir.py:351:2: W0511: TODO: improve this so tensor products print like "x a, y b;" (fixme)
************* Module qdata.parser
qdata/parser.py:184:2: W0511: TODO: this seems to only be called from a single location; the OPAQUE (fixme)
qdata/parser.py:243:2: W0511: TODO: Add proper parser validation and exceptions, including returning (fixme)
qdata/parser.py:263:2: W0511: TODO: check that this still holds (fixme)
qdata/parser.py:295:2: W0511: TODO: Check the operator kind this 'catch-all' return (fixme)
qdata/parser.py:323:2: W0511: TODO: should we add support for more primitives/intrinsic gates? OpenQASM 2.0 will likely (fixme)
qdata/parser.py:366:2: W0511: TODO: consider extending the grammar so users can specify (fixme)
qdata/parser.py:372:2: W0511: TODO: this case should not occur, according (fixme)
qdata/parser.py:412:2: W0511: TODO: This definition doesn't really make sense. The mixedlist (fixme)
qdata/parser.py:465:2: W0511: TODO: Check what happens if a negative integer is specified. This will likely (fixme)
qdata/parser.py:469:2: W0511: TODO: support parameters that start with a capital letter? (fixme)
qdata/parser.py:482:2: W0511: TODO: Have proper validation here (fixme)
qdata/parser.py:190:8: W0612: Unused variable 'idlist1' (unused-variable)
------------------------------------------------------------------
Your code has been rated at 9.72/10 (previous run: 7.81/10, +1.91)
Context: Before writing a test suite, it makes sense to first perform static analysis of the code, in order to catch any obvious bugs and deficiencies. This ensures that we begin writing functional tests from a higher level of quality. It also will allow us to better keep track of TODOs present in the source code.
Description of changes:
A
.pylintrc
config file is added to ensure some sensible defaults.The
qdata/
folder was linted, and any reported bugs fixed. This includes:The
insert_includes
keyword argument was not correctly serializing the included files when set toTrue
. This has been fixed; in addition, it was renamed toinline
. This is inspired from C, whereinline
instructs the compiler to 'inline' any header definitions. Here, we use the term to instruct the serializer to 'inline' any included files.The OpenQASM version was being set to
2.0
by default, even if not specified in the parsed file. This does not make sense; the IR should reflect the parsed file exactly. The default has been changed toNone
.The
Ops.RESET
enum has been added to the IR, and used within the parser.Redundant
super()
calls were removed.Docstrings were added where missing.
Unused imports were removed.
In some cases, keyword arguments were being used incorrectly (e.g., kwargs before args, kwargs not being defined). This has been corrected.
Finally, while linting, future tasks/issues were noted via
TODO
comments.Benefits:
Code is now slightly cleaner, which should help with new developer onboarding.
Minimal docstrings have been added, which should help with development/keeping track of relationships between methods.
Various bugs have been fixed.
It is now easier to keep track of TODOs, via pylint:
Next steps: