Docs: More type annotation changes (#5301)

* Update docs annotations

* Update settings recommendation

* Remove Dict in comment
This commit is contained in:
Duck
2025-09-30 10:32:50 -06:00
committed by GitHub
parent 516ebc53ce
commit 1d2ad1f9c9
5 changed files with 19 additions and 16 deletions

View File

@@ -15,8 +15,10 @@
* Prefer [format string literals](https://peps.python.org/pep-0498/) over string concatenation,
use single quotes inside them: `f"Like {dct['key']}"`
* Use type annotations where possible for function signatures and class members.
* Use type annotations where appropriate for local variables (e.g. `var: List[int] = []`, or when the
type is hard or impossible to deduce.) Clear annotations help developers look up and validate API calls.
* Use type annotations where appropriate for local variables (e.g. `var: list[int] = []`, or when the
type is hard or impossible to deduce). Clear annotations help developers look up and validate API calls.
* Prefer new style type annotations for new code (e.g. `var: dict[str, str | int]` over
`var: Dict[str, Union[str, int]]`).
* If a line ends with an open bracket/brace/parentheses, the matching closing bracket should be at the
beginning of a line at the same indentation as the beginning of the line with the open bracket.
```python