What's New In Pylint 1.6#
Summary -- Release highlights#
We added a new recommendation check,
consider-iterating-dictionary, which is emitted when a dictionary is iterated by using
For instance, the following code would trigger this warning, since the dictionary's keys can be iterated without calling the method explicitly.
for key in dictionary.keys(): ... # Can be refactored to: for key in dictionary: ...
trailing-newlinescheck was added, which is emitted when a file has trailing newlines.
invalid-length-returnedcheck was added, which is emitted when the
__len__special method returns something else than a non-negative number. For instance, this example is triggering it:
class Container(object): def __len__(self): return self._items # Oups, forgot to call len() over it.
Add a new check to the check_docs extension for looking for duplicate constructor parameters in a class constructor docstring or in a class docstring.
multiple-constructor-docis emitted when the parameter is documented in both places.
We added a new extension plugin,
pylint.extensions.mccabe, which can be used for warning about the complexity in the code.
You can enable it as in:
$ pylint module_or_project --load-plugins=pylint.extensions.mccabe
See more at Design checker
generated-membersnow supports qualified names through regular expressions.
For instance, for ignoring all the errors generated by
numpy.core's attributes, we can now use:
$ pylint a.py --generated-members=numpy.*
Add the ability to ignore files based on regex matching, with the new
Rather than clobber the existing
ignoreoption, we decided to have a separate option for it. For instance, for ignoring all the test files, we can now use:
$ pylint myproject --ignore-patterns=test.*?py
We added a new option,
redefining-builtins-modules, which is used for defining the modules which can redefine builtins. pylint will emit an error when a builtin is redefined, such as defining a variable called
next. But in some cases, the builtins can be redefined in the case they are imported from other places, different than the
builtinsmodule, such is the case for
six.moves, which contains more forward-looking functions:
$ cat a.py # Oups, now pylint emits a redefined-builtin message. from six.moves import open $ pylint a.py --redefining-builtins-modules=six.moves
Fixed a bug where the top name of a qualified import was detected as an unused variable.
We don't warn about
invalid-sequence-indexif the indexed object has unknown base classes, that Pylint cannot deduce.
bad-builtincheck was moved into an extension.
The check was complaining about used builtin functions which were supposed to not be used. For instance,
filterwere falling into this category, since better alternatives can be used, such as list comprehensions. But the check was annoying, since using
filtercan have its use cases and as such, we decided to move it to an extension check instead. It can now be enabled through
We use the
configparserbackport internally, for Python 2.
This allows having comments inside list values, in the configuration, such as:
disable=no-member, # Don't like this check bad-indentation
We now use the isort package internally.
This improves the
`wrong-import-ordercheck, so now we should have less false positives regarding the import order.
We do not emit
no-name-in-modulefor fallback import blocks by default.
A fallback import block can be considered a TryExcept block, which contains imports in both branches, such as:
try: import urllib.request as request except ImportError: import urllib2 as request
In the case where pylint can not find one import from the
exceptbranch, then it will emit an
import-error, but this gets cumbersome when trying to write compatible code for both Python versions. As such, we don't check these blocks by default, but the analysis can be enforced by using the new
reimportedis emitted when the same name is imported from different module, as in:
from collections import deque, OrderedDict, deque
The HTML support was deprecated and will be eventually removed in Pylint 1.7.0.
This feature was lately a second class citizen in Pylint, being often neglected and having a couple of bugs. Since we now have the JSON reporter, this can be used as a basis for more prettier HTML outputs than what Pylint can currently offer.
--files-outputoption was deprecated and will be eventually removed in Pylint 1.7.0.
--optimize-astoption was deprecated and will be eventually removed in Pylint 1.7.0.
The option was initially added for handling pathological cases, such as joining too many strings using the addition operator, which was leading pylint to have a recursion error when trying to figure out what the string was. Unfortunately, we decided to ignore the issue, since the pathological case would have happen when the code was parsed by Python as well, without actually reaching the runtime step and as such, we will remove the option in the future.
check_docsextension is now deprecated. The extension is still available under the
docparamsname, so this should work:
$ pylint module_or_package --load-extensions=pylint.extensions.docparams
The old name is still kept for backward compatibility, but it will be eventually removed.