Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reason for low Pylint ratings of Python standard library code

Tags:

python

pylint

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 :)

like image 914
Joshua Avatar asked Jul 28 '10 18:07

Joshua


People also ask

How can I improve my pylint score?

Upgrading Pylint To upgrade to the absolute latest version, run the following command: pip install pylint --upgrade.

What is good pylint score?

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.

How is pylint score calculated?

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).


1 Answers

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'
like image 116
Ned Batchelder Avatar answered Oct 05 '22 07:10

Ned Batchelder