diff --git a/docs/development/developer-guide.rst b/docs/development/developer-guide.rst index 8c9142fc308..43c7b71a9bc 100644 --- a/docs/development/developer-guide.rst +++ b/docs/development/developer-guide.rst @@ -131,3 +131,22 @@ simple Python script ``tools/vendor.py``. To refresh the dependencies, run the following command:: $ tox -e vendor + +---------------- +Type annotations +---------------- + +Setuptools makes use of inferred return annotations to reduce verbosity, +especially for complex return types. Explicit return types can be added for +functions whose inferred return type contains ``Any``, or that are not checked by +mypy (ie.: contains no parameter *and* no return type, see +[python/mypy#4409](https://github.com/python/mypy/issues/4409), +[python/mypy#10149](https://github.com/python/mypy/issues/10149) and +[python/mypy#6646](https://github.com/python/mypy/issues/6646) ). + +Instead of typing an explicit return type annotation as +``Generator[..., None, None]``, we'll prefer using an ``Iterator`` as it is more +concise and conceptually easier to deal with. Returning a ``Generator`` with no +``yield`` type or ``send`` type can sometimes be considered as exposing +implementation details. See +[Y058](https://github.com/PyCQA/flake8-pyi/blob/main/ERRORCODES.md#Y058).