What's New in Pylint 2.5¶
- Release
2.5
- Date
2020-04-27
Summary -- Release highlights¶
New checkers¶
A new check
isinstance-second-argument-not-valid-typewas added.This check is emitted whenever pylint finds a call to the
isinstancefunction with a second argument that is not a type. Such code is likely unintended as it will cause a TypeError to be thrown at runtime error.A new check
assert-on-string-literalwas added.This check is emitted whenever pylint finds an assert statement with a string literal as its first argument. Such assert statements are probably unintended as they will always pass.
A new check
f-string-without-interpolationwas added.This check is emitted whenever pylint detects the use of an f-string without having any interpolated values in it, which means that the f-string can be a normal string.
Multiple checks for invalid return types of protocol functions were added:
invalid-bool-returned:__bool__did not return a boolinvalid-index-returned:__index__did not return an integerinvalid-repr-returned):__repr__did not return a stringinvalid-str-returned):__str__did not return a stringinvalid-bytes-returned):__bytes__did not return a stringinvalid-hash-returned):__hash__did not return an integerinvalid-length-hint-returned):__length_hint__did not return a non-negative integerinvalid-format-returned):__format__did not return a stringinvalid-getnewargs-returned):__getnewargs__did not return a tupleinvalid-getnewargs-ex-returned):__getnewargs_ex__did not return a tuple of the form (tuple, dict)
A new check
inconsistent-quoteswas added.This check is emitted when quotes delimiters (
"and') are not used consistently throughout a module. It allows avoiding unnecessary escaping, allowing, for example,"Don't error"in a module in which single-quotes otherwise delimit strings so that the single quote inDon'tdoesn't need to be escaped.A new check
non-str-assignment-to-dunder-namewas added to ensure that only strings are assigned to__name__attributes.
Other Changes¶
Configuration can be read from a setup.cfg or pyproject.toml file in the current directory. A setup.cfg must prepend pylintrc section names with
pylint., for example[pylint.MESSAGES CONTROL]. A pyproject.toml file must prepend section names withtool.pylint., for example[tool.pylint.'MESSAGES CONTROL']. These files can also be passed in on the command line.Add new
good-names-rgxandbad-names-rgxto enable permitting or disallowing of names via regular expressionsTo enable better handling of permitted/disallowed names, we added two new config options: good-names-rgxs: a comma- separated list of regexes, that if a name matches will be exempt of naming-checking. bad-names-rgxs: a comma- separated list of regexes, that if a name matches will be always marked as a disallowed name.
Mutable
collections.*are now flagged as dangerous defaults.Add new
--fail-underflag for setting the threshold for the score to fail overall tests. If the score is over the fail-under threshold, pylint will complete SystemExit with value 0 to indicate no errors.Added a new option
notes-rgxto make fixme warnings more flexible. Now eithernotesornotes-rgxoption can be used to detect fixme warnings.Non-ASCII characters are now allowed by
invalid-name.pylintno longer emitsinvalid-namefor non-constants found at module level.Pylint was considering all module level variables as constants, which is not what PEP 8 is actually mandating.
A new check
non-ascii-namewas added to detect identifiers with non-ASCII characters.Overloaded typing functions no longer trigger
no-self-use,unused-argument,missing-docstringand similar checks that assumed that overloaded functions are normal functions.python -m pylintcan no longer be made to import files from the local directory.A new command
--list-extensionswas added.This command lists all extensions present in
pylint.extensions.Various false positives have been fixed which you can read more about in the Changelog files.
Multiple types of string formatting are allowed in logging functions.
The logging-fstring-interpolation message has been brought back to allow
multiple types of string formatting to be used.
The type of formatting to use is chosen through enabling and disabling messages
rather than through the logging-format-style option.
The fstr value of the logging-format-style option is not valid.
