| 1 |
:Release: 1.6.0 |
| 2 |
:Date: 2016-07-07 |
| 3 |
|
| 4 |
Summary -- Release highlights |
| 5 |
============================= |
| 6 |
|
| 7 |
Nothing major. |
| 8 |
|
| 9 |
|
| 10 |
New checkers |
| 11 |
============ |
| 12 |
|
| 13 |
* We added a new recommendation check, ``consider-iterating-dictionary``, |
| 14 |
which is emitted when a dictionary is iterated by using ``.keys()``. |
| 15 |
|
| 16 |
For instance, the following code would trigger this warning, since |
| 17 |
the dictionary's keys can be iterated without calling the method explicitly. |
| 18 |
|
| 19 |
.. code-block:: python |
| 20 |
|
| 21 |
for key in dictionary.keys(): |
| 22 |
... |
| 23 |
|
| 24 |
# Can be refactored to: |
| 25 |
for key in dictionary: |
| 26 |
... |
| 27 |
|
| 28 |
* ``trailing-newlines`` check was added, which is emitted when a file has trailing newlines. |
| 29 |
|
| 30 |
|
| 31 |
* ``invalid-length-returned`` check was added, which is emitted when the ``__len__`` |
| 32 |
special method returns something else than a non-negative number. For instance, this |
| 33 |
example is triggering it:: |
| 34 |
|
| 35 |
class Container(object): |
| 36 |
def __len__(self): |
| 37 |
return self._items # Oups, forgot to call len() over it. |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
* Add a new check to the *check_docs* extension for looking for duplicate |
| 42 |
constructor parameters in a class constructor docstring or in a class docstring. |
| 43 |
|
| 44 |
The check ``multiple-constructor-doc`` is emitted when the parameter is documented |
| 45 |
in both places. |
| 46 |
|
| 47 |
|
| 48 |
* We added a new extension plugin, ``pylint.extensions.mccabe``, which can be used |
| 49 |
for warning about the complexity in the code. |
| 50 |
|
| 51 |
You can enable it as in:: |
| 52 |
|
| 53 |
$ pylint module_or_project --load-plugins=pylint.extensions.mccabe |
| 54 |
|
| 55 |
See more at :ref:`pylint.extensions.mccabe` |
| 56 |
|
| 57 |
|
| 58 |
New features |
| 59 |
============ |
| 60 |
|
| 61 |
* ``generated-members`` now supports qualified names through regular expressions. |
| 62 |
|
| 63 |
For instance, for ignoring all the errors generated by ``numpy.core``'s attributes, we can |
| 64 |
now use:: |
| 65 |
|
| 66 |
$ pylint a.py --generated-members=numpy.* |
| 67 |
|
| 68 |
|
| 69 |
* Add the ability to ignore files based on regex matching, with the new ``--ignore-patterns`` option. |
| 70 |
|
| 71 |
Rather than clobber the existing ``ignore`` option, we decided to have a separate |
| 72 |
option for it. For instance, for ignoring all the test files, we can now use:: |
| 73 |
|
| 74 |
$ pylint myproject --ignore-patterns=test.*?py |
| 75 |
|
| 76 |
|
| 77 |
* We added a new option, ``redefining-builtins-modules``, which is used for |
| 78 |
defining the modules which can redefine builtins. |
| 79 |
*pylint* will emit an error when a builtin is redefined, such as defining |
| 80 |
a variable called ``next``. But in some cases, the builtins can be |
| 81 |
redefined in the case they are imported from other places, different |
| 82 |
than the ``builtins`` module, such is the case for ``six.moves``, which |
| 83 |
contains more forward-looking functions:: |
| 84 |
|
| 85 |
$ cat a.py |
| 86 |
# Oups, now pylint emits a redefined-builtin message. |
| 87 |
from six.moves import open |
| 88 |
$ pylint a.py --redefining-builtins-modules=six.moves |
| 89 |
|
| 90 |
Default values: ``six.moves,future.builtins`` |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
Bug fixes |
| 95 |
========= |
| 96 |
|
| 97 |
* Fixed a bug where the top name of a qualified import was detected as an unused variable. |
| 98 |
|
| 99 |
* We don't warn about ``invalid-sequence-index`` if the indexed object has unknown |
| 100 |
base classes, that Pylint cannot deduce. |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
Other Changes |
| 105 |
============= |
| 106 |
|
| 107 |
|
| 108 |
* The ``bad-builtin`` check was moved into an extension. |
| 109 |
|
| 110 |
The check was complaining about used builtin functions which |
| 111 |
were supposed to not be used. For instance, ``map`` and ``filter`` |
| 112 |
were falling into this category, since better alternatives can |
| 113 |
be used, such as list comprehensions. But the check was annoying, |
| 114 |
since using ``map`` or ``filter`` can have its use cases and as |
| 115 |
such, we decided to move it to an extension check instead. |
| 116 |
It can now be enabled through ``--load-plugins=pylint.extensions.bad_builtin``. |
| 117 |
|
| 118 |
* We use the ``configparser`` backport internally, for Python 2. |
| 119 |
|
| 120 |
This allows having comments inside list values, in the configuration, |
| 121 |
such as:: |
| 122 |
|
| 123 |
disable=no-member, |
| 124 |
# Don't like this check |
| 125 |
bad-indentation |
| 126 |
|
| 127 |
* We now use the isort_ package internally. |
| 128 |
|
| 129 |
This improves the ```wrong-import-order`` check, so now |
| 130 |
we should have less false positives regarding the import order. |
| 131 |
|
| 132 |
|
| 133 |
* We do not emit ``import-error`` or ``no-name-in-module`` for fallback import blocks by default. |
| 134 |
|
| 135 |
A fallback import block can be considered a TryExcept block, which contains imports in both |
| 136 |
branches, such as:: |
| 137 |
|
| 138 |
try: |
| 139 |
import urllib.request as request |
| 140 |
except ImportError: |
| 141 |
import urllib2 as request |
| 142 |
|
| 143 |
In the case where **pylint** can not find one import from the ``except`` branch, then |
| 144 |
it will emit an ``import-error``, but this gets cumbersome when trying to write |
| 145 |
compatible code for both Python versions. As such, we don't check these blocks by default, |
| 146 |
but the analysis can be enforced by using the new ``--analyse-fallback-block`` flag. |
| 147 |
|
| 148 |
* ``reimported`` is emitted when the same name is imported from different module, as in:: |
| 149 |
|
| 150 |
from collections import deque, OrderedDict, deque |
| 151 |
|
| 152 |
|
| 153 |
Deprecated features |
| 154 |
=================== |
| 155 |
|
| 156 |
* The HTML support was deprecated and will be eventually removed |
| 157 |
in Pylint 1.7.0. |
| 158 |
|
| 159 |
This feature was lately a second class citizen in Pylint, being |
| 160 |
often neglected and having a couple of bugs. Since we now have |
| 161 |
the JSON reporter, this can be used as a basis for more prettier |
| 162 |
HTML outputs than what Pylint can currently offer. |
| 163 |
|
| 164 |
* The ``--files-output`` option was deprecated and will be eventually |
| 165 |
removed in Pylint 1.7.0. |
| 166 |
|
| 167 |
* The ``--optimize-ast`` option was deprecated and will be eventually |
| 168 |
removed in Pylint 1.7.0. |
| 169 |
|
| 170 |
The option was initially added for handling pathological cases, |
| 171 |
such as joining too many strings using the addition operator, which |
| 172 |
was leading pylint to have a recursion error when trying to figure |
| 173 |
out what the string was. Unfortunately, we decided to ignore the |
| 174 |
issue, since the pathological case would have happen when the |
| 175 |
code was parsed by Python as well, without actually reaching the |
| 176 |
runtime step and as such, we will remove the option in the future. |
| 177 |
|
| 178 |
* The ``check_docs`` extension is now deprecated. The extension is still available |
| 179 |
under the ``docparams`` name, so this should work:: |
| 180 |
|
| 181 |
$ pylint module_or_package --load-extensions=pylint.extensions.docparams |
| 182 |
|
| 183 |
The old name is still kept for backward compatibility, but it will be |
| 184 |
eventually removed. |
| 185 |
|
| 186 |
|
| 187 |
Removed features |
| 188 |
================ |
| 189 |
|
| 190 |
* None yet |
| 191 |
|
| 192 |
.. _isort: https://pypi.org/project/isort/ |