From cc9cdf01b44556db91739d3af70dd3d4a3827e43 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Mon, 16 Dec 2024 22:35:37 -0800 Subject: [PATCH] Minor style and formatting fixes Removed repeated example, fixed formatting, removed stray "the". --- docs/guides/writing_stubs.rst | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/docs/guides/writing_stubs.rst b/docs/guides/writing_stubs.rst index 71b5d0eb..47f48b40 100644 --- a/docs/guides/writing_stubs.rst +++ b/docs/guides/writing_stubs.rst @@ -234,15 +234,7 @@ follow the following guidelines: can be left unannotated. * Do not use ``Any`` to mark unannotated or partially annotated values. Leave function parameters and return values unannotated. In all other cases, use - ``_typeshed.Incomplete``:: - - from _typeshed import Incomplete - - field1: Incomplete - field2: dict[str, Incomplete] - - def foo(x): ... - + ``_typeshed.Incomplete``. * Partial classes should include a ``__getattr__()`` method marked with ``_typeshed.Incomplete`` (see example below). * Partial modules (i.e. modules that are missing some or all classes, @@ -782,6 +774,7 @@ Using ``Any`` and ``object`` When adding type hints, avoid using the ``Any`` type when possible. Reserve the use of ``Any`` for when: + * the correct type cannot be expressed in the current type system; and * to avoid union returns (see above). @@ -830,7 +823,7 @@ context manager is meant to be subclassed, pick ``bool | None``. See https://github.com/python/mypy/issues/7214 for more details. ``__enter__`` methods and other methods that return ``self`` or ``cls(...)`` -should be annotated with the `typing.Self` +should be annotated with ``typing.Self`` (`example `_). Naming