A friend told me about Pylint and just out of curiosity, I ran it against some of the standard library modules. To my surprise, the ratings were low. Here are a few runs:
os.py
Your code has been rated at 3.55/10
random.py
Your code has been rated at 4.74/10
I ran it on some more modules and the found the rating to be ~ 6 - 7.
I was wondering the reason behind this? Is Pylint broken or there are more factors to the rating than I am aware of? I am asking this question particularly cause I am new to Python and was depending on Pylint to help me improve my coding style :)
Upgrading Pylint To upgrade to the absolute latest version, run the following command: pip install pylint --upgrade.
In python, the most consensual writing style is defined by the PEP-8 standard, which the popular pylint package enforces. It comes with a handy metric, the Pylint score: you get a 10/10 for perfectly conforming to the standard, less it you stray from it.
The score is calculated using Pylint version 2.4. 3 To calculate the coding convention score, we will use the standard coding convention score calculated by Pylint. The formula for this score is as follows: 10.0 - ((float(5 * Frequency of convention errors) / Number of statement) * 10).
Pylint's defaults are quite strict, and complain about things they should not. For example, if you use foo(**kwargs)
, you get a message about using "magic". Sometimes it seems as if pylint is looking at Python from a Java programmer's point of view.
You'd have to look at the specific messages and decide if you agree with them.
Other problems include not being able to do platform-specific conditionals. In os.py, it complains:
F:119: Unable to import 'riscos'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With