babbush / HistoricalFermiLib

This is repo where we developed FermiLib, which then became OpenFermion
Apache License 2.0
1 stars 0 forks source link

Consider using pylint to improve code style. #25

Closed Spaceenter closed 7 years ago

Spaceenter commented 7 years ago

@babbush The current code is already pretty easy to read, but using pylint (or equivalent automatic tools) could help us improve the code style / readability greatly, which should be important for future users to read the source code. Specifically, pylint helps us to adapt to this style guide: https://google.github.io/styleguide/pyguide.html

I tried "pylint fermion_operators.py", and seems there are some room for improvements:

Messages

+------------------------------+------------+ |message id |occurrences | +==============================+============+ |bad-indentation |216 | +------------------------------+------------+ |invalid-name |9 | +------------------------------+------------+ |relative-import |6 | +------------------------------+------------+ |missing-docstring |6 | +------------------------------+------------+ |anomalous-backslash-in-string |5 | +------------------------------+------------+ |no-member |4 | +------------------------------+------------+ |wrong-import-order |1 | +------------------------------+------------+ |unused-import |1 | +------------------------------+------------+ |redefined-variable-type |1 | +------------------------------+------------+ |consider-using-enumerate |1 | +------------------------------+------------+ |bad-continuation |1 | +------------------------------+------------+

Global evaluation

Your code has been rated at -3.15/10

Spaceenter commented 7 years ago

Also, I feel a simple script to run all the tests and lint checks would be handy and useful, so that each time before submitting pull request / checking in, we won't introduce new errors.

babbush commented 7 years ago

Currently, we have been following the pep8 style guide and have been requesting that people use the pep8 linter with the following modifications to ~/.config/pep8: ignore = E111, E114, E226.

We have talked about requiring the linter prior to submission. @damiansteiger and @thomashaener, do you guys have thoughts about this? I have mentioned the idea before and I think it would be beneficial for ProjectQ as well.

Wei, would you be happy if we mandated running the pep8 linter or do you think there is a strong case to be made for using the Google style guide in particular. Keep in mind that most contributors are not at Google.

Spaceenter commented 7 years ago

Yes, pep8 should also work well. It's a bit weird that pylint and pep8 disagrees with each other so much :) Thanks.