Debian Codegraph @

doc/whatsnew/2/2.5/summary.rst

raw
1 :Release: 2.5
2 :Date: 2020-04-27
3
4
5 Summary -- Release highlights
6 =============================
7
8
9 New checkers
10 ============
11
12 * A new check ``isinstance-second-argument-not-valid-type`` was added.
13
14 This check is emitted whenever **pylint** finds a call to the ``isinstance``
15 function with a second argument that is not a type. Such code is likely
16 unintended as it will cause a TypeError to be thrown at runtime error.
17
18 * A new check ``assert-on-string-literal`` was added.
19
20 This check is emitted whenever **pylint** finds an assert statement
21 with a string literal as its first argument. Such assert statements
22 are probably unintended as they will always pass.
23
24 * A new check ``f-string-without-interpolation`` was added.
25
26 This check is emitted whenever **pylint** detects the use of an
27 f-string without having any interpolated values in it, which means
28 that the f-string can be a normal string.
29
30 * Multiple checks for invalid return types of protocol functions were added:
31
32 * ``invalid-bool-returned``: ``__bool__`` did not return a bool
33 * ``invalid-index-returned``: ``__index__`` did not return an integer
34 * ``invalid-repr-returned)``: ``__repr__`` did not return a string
35 * ``invalid-str-returned)``: ``__str__`` did not return a string
36 * ``invalid-bytes-returned)``: ``__bytes__`` did not return a string
37 * ``invalid-hash-returned)``: ``__hash__`` did not return an integer
38 * ``invalid-length-hint-returned)``: ``__length_hint__`` did not return a non-negative integer
39 * ``invalid-format-returned)``: ``__format__`` did not return a string
40 * ``invalid-getnewargs-returned)``: ``__getnewargs__`` did not return a tuple
41 * ``invalid-getnewargs-ex-returned)``: ``__getnewargs_ex__`` did not return a tuple of the form (tuple, dict)
42
43 * A new check ``inconsistent-quotes`` was added.
44
45 This check is emitted when quotes delimiters (``"`` and ``'``) are not used
46 consistently throughout a module. It allows avoiding unnecessary escaping,
47 allowing, for example, ``"Don't error"`` in a module in which single-quotes
48 otherwise delimit strings so that the single quote in ``Don't`` doesn't need to be escaped.
49
50 * A new check ``non-str-assignment-to-dunder-name`` was added to ensure that only strings are assigned to ``__name__`` attributes.
51
52
53 Other Changes
54 =============
55
56 * Configuration can be read from a setup.cfg or pyproject.toml file in the current directory.
57 A setup.cfg must prepend pylintrc section names with ``pylint.``, for example ``[pylint.MESSAGES CONTROL]``.
58 A pyproject.toml file must prepend section names with ``tool.pylint.``, for example ``[tool.pylint.'MESSAGES CONTROL']``.
59 These files can also be passed in on the command line.
60
61 * Add new ``good-names-rgx`` and ``bad-names-rgx`` to enable permitting or disallowing of names via regular expressions
62
63 To enable better handling of permitted/disallowed names, we added two new config options: good-names-rgxs: a comma-
64 separated list of regexes, that if a name matches will be exempt from naming-checking. bad-names-rgxs: a comma-
65 separated list of regexes, that if a name matches will be always marked as a disallowed name.
66
67 * Mutable ``collections.*`` are now flagged as dangerous defaults.
68
69 * Add new ``--fail-under`` flag 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.
70
71 * Added a new option ``notes-rgx`` to make fixme warnings more flexible. Now either ``notes`` or ``notes-rgx`` option can be used to detect fixme warnings.
72
73 * Non-ASCII characters are now allowed by ``invalid-name``.
74
75 * ``pylint`` no longer emits ``invalid-name`` for non-constants found at module level.
76
77 Pylint was considering all module level variables as constants, which is not what PEP 8 is actually mandating.
78
79 * A new check ``non-ascii-name`` was added to detect identifiers with non-ASCII characters.
80
81 * Overloaded typing functions no longer trigger ``no-self-use``, ``unused-argument``, ``missing-docstring`` and similar checks
82 that assumed that overloaded functions are normal functions.
83
84 * ``python -m pylint`` can no longer be made to import files from the local directory.
85
86 * A new command ``--list-extensions`` was added.
87
88 This command lists all extensions present in ``pylint.extensions``.
89
90 * Various false positives have been fixed which you can read more about in the Changelog files.
91
92 * Multiple types of string formatting are allowed in logging functions.
93
94 The ``logging-fstring-interpolation`` message has been brought back to allow
95 multiple types of string formatting to be used.
96 The type of formatting to use is chosen through enabling and disabling messages
97 rather than through the logging-format-style option.
98 The fstr value of the logging-format-style option is not valid.