Skip to content

Commit

Permalink
Add Type annotations developer guideline
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed May 24, 2024
1 parent 33afc11 commit 818da0c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/development/developer-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit 818da0c

Please sign in to comment.