8000 Move truthy-function docs from “optional checks” to “enabled by default” · python/mypy@be1bfe9 · GitHub
[go: up one dir, main page]

Skip to content

Commit be1bfe9

Browse files
committed
Move truthy-function docs from “optional checks” to “enabled by default”
This error was enabled by default since its introduction (#13686); document it in the correct section. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
1 parent 47a435f commit be1bfe9

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

docs/source/error_code_list.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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

docs/source/error_code_list2.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -256,19 +256,6 @@ what the author might have intended. Of course it's possible that ``transform``
256256
and so there is no error in practice. In such case, it is recommended to annotate ``items: Collection[int]``.
257257

258258

259-
Check that function isn't used in boolean context [truthy-function]
260-
-------------------------------------------------------------------
261-
262-
Functions will always evaluate to true in boolean contexts.
263-
264-
.. code-block:: python
265-
266-
def f():
267-
...
268-
269-
if f: # Error: Function "Callable[[], Any]" could always be true in boolean context [truthy-function]
270-
pass
271-
272259
.. _ignore-without-code:
273260

274261
Check that ``# type: ignore`` include an error code [ignore-without-code]

0 commit comments

Comments
 (0)
0