File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed
Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -764,6 +764,19 @@ the provided type.
764764
765765 assert_type([1 ], list[str ]) # Error
766766
767+ Check that function isn't used in boolean context [truthy-function]
768+ -------------------------------------------------------------------
769+
770+ Functions will always evaluate to true in boolean contexts.
771+
772+ .. code-block :: python
773+
774+ def f ():
775+ ...
776+
777+ if f: # Error: Function "Callable[[], Any]" could always be true in boolean context [truthy-function]
778+ pass
779+
767780 Report syntax errors [syntax]
768781-----------------------------
769782
Original file line number Diff line number Diff line change @@ -275,19 +275,6 @@ what the author might have intended. Of course it's possible that ``transform``
275275and so there is no error in practice. In such case, it is recommended to annotate ``items: Collection[int] ``.
276276
277277
278- Check that function isn't used in boolean context [truthy-function]
279- -------------------------------------------------------------------
280-
281- Functions will always evaluate to true in boolean contexts.
282-
283- .. code-block :: python
284-
285- def f ():
286- ...
287-
288- if f: # Error: Function "Callable[[], Any]" could always be true in boolean context [truthy-function]
289- pass
290-
291278.. _ignore-without-code :
292279
293280Check that ``# type: ignore `` include an error code [ignore-without-code]
You can’t perform that action at this time.
0 commit comments