You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -173,6 +173,7 @@ using ``pytest.raises``), or use the context manager form with a target
173
173
.. _B018:
174
174
175
175
**B018**: Found useless expression. Either assign it to a variable or remove it.
176
+
The check also considers function calls without side-effects such as ``isinstance``.
176
177
Note that dangling commas will cause things to be interpreted as useless tuples.
177
178
For example, in the statement ``print(".."),`` is the same as ``(print(".."),)``
178
179
which is an unassigned tuple. Simply remove the comma to clear the error.
@@ -292,16 +293,16 @@ second usage. Save the result to a list if the result is needed multiple times.
292
293
293
294
.. _B042:
294
295
295
-
**B042**: Exception classes with a custom `__init__` should pass all args to `super().__init__()` to work correctly with `copy.copy` and `pickle`.
296
-
Both `BaseException.__reduce__` and `BaseException.__str__` rely on the `args` attribute being set correctly, which is set in `BaseException.__new__` and `BaseException.__init__`.
297
-
If you define `__init__` yourself without passing all arguments to `super().__init__` it is very easy to break pickling, especially if they pass keyword arguments which both
298
-
`BaseException.__new__` and `BaseException.__init__` ignore. It's also important that `__init__` not accept any keyword-only parameters.
299
-
Alternately you can define both `__str__` and `__reduce__` to bypass the need for correct handling of `args`.
296
+
**B042**: Exception classes with a custom `__init__` should pass all args to `super().__init__()` to work correctly with `copy.copy` and `pickle`.
297
+
Both `BaseException.__reduce__` and `BaseException.__str__` rely on the `args` attribute being set correctly, which is set in `BaseException.__new__` and `BaseException.__init__`.
298
+
If you define `__init__` yourself without passing all arguments to `super().__init__` it is very easy to break pickling, especially if they pass keyword arguments which both
299
+
`BaseException.__new__` and `BaseException.__init__` ignore. It's also important that `__init__` not accept any keyword-only parameters.
300
+
Alternately you can define both `__str__` and `__reduce__` to bypass the need for correct handling of `args`.
300
301
If you define `__str__/__reduce__` in super classes this check is unable to detect it, and we advise disabling it.
301
302
302
303
.. _B043:
303
304
304
-
**B043**: Do not call ``delattr(x, 'attr')``, instead use ``del x.attr``.
305
+
**B043**: Do not call ``delattr(x, 'attr')``, instead use ``del x.attr``.
305
306
There is no additional safety in using ``delattr`` if you know the attribute name ahead of time.
306
307
307
308
@@ -494,6 +495,11 @@ MIT
494
495
Change Log
495
496
----------
496
497
498
+
UNRELEASED
499
+
~~~~~~~~~~
500
+
501
+
* B018: handle also useless calls such as `isinstance(x, int)` without assigning or using the result
0 commit comments