docs: Add an additional truthiness antipattern to mypy best practices.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-04-12 14:36:18 -07:00
parent c4b60acf9c
commit fb3bfce513
1 changed files with 3 additions and 3 deletions

View File

@ -376,9 +376,9 @@ collection. For example:
* An exclude list where the default is to exclude nothing should be
non-`Optional` with default `[]`.
Don't test an `Optional` value using truthiness (`if value:` or `if
not value:`), especially when the type might have falsy values other
than `None`.
Don't test an `Optional` value using truthiness (`if value:`, `not
value`, `value or default_value`), especially when the type might have
falsy values other than `None`.
```python
s: Optional[str]