From be1bfe951c19047eb00563e223339ba68da763a8 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 2 Jan 2023 21:27:42 -0800 Subject: [PATCH] =?UTF-8?q?Move=20truthy-function=20docs=20from=20?= =?UTF-8?q?=E2=80=9Coptional=20checks=E2=80=9D=20to=20=E2=80=9Cenabled=20b?= =?UTF-8?q?y=20default=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This error was enabled by default since its introduction (#13686); document it in the correct section. Signed-off-by: Anders Kaseorg --- docs/source/error_code_list.rst | 13 +++++++++++++ docs/source/error_code_list2.rst | 13 ------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 264badc03107..1a39bf8feb6c 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -764,6 +764,19 @@ the provided type. assert_type([1], list[str]) # Error +Check that function isn't used in boolean context [truthy-function] +------------------------------------------------------------------- + +Functions will always evaluate to true in boolean contexts. + +.. code-block:: python + + def f(): + ... + + if f: # Error: Function "Callable[[], Any]" could always be true in boolean context [truthy-function] + pass + Report syntax errors [syntax] ----------------------------- diff --git a/docs/source/error_code_list2.rst b/docs/source/error_code_list2.rst index 0a2d8a8c5c5c..986118c4f0da 100644 --- a/docs/source/error_code_list2.rst +++ b/docs/source/error_code_list2.rst @@ -256,19 +256,6 @@ what the author might have intended. Of course it's possible that ``transform`` and so there is no error in practice. In such case, it is recommended to annotate ``items: Collection[int]``. -Check that function isn't used in boolean context [truthy-function] -------------------------------------------------------------------- - -Functions will always evaluate to true in boolean contexts. - -.. code-block:: python - - def f(): - ... - - if f: # Error: Function "Callable[[], Any]" could always be true in boolean context [truthy-function] - pass - .. _ignore-without-code: Check that ``# type: ignore`` include an error code [ignore-without-code]