Skip to content

Commit 2401c13

Browse files
committed
Add Type annotations developer guideline
1 parent 33afc11 commit 2401c13

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/development/developer-guide.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,22 @@ simple Python script ``tools/vendor.py``.
131131
To refresh the dependencies, run the following command::
132132

133133
$ tox -e vendor
134+
135+
----------------
136+
Type annotations
137+
----------------
138+
139+
Setuptools makes use of inferred return annotations to reduce verbosity,
140+
especially for complex return types. Explicit return types can be added for
141+
functions whose inferred return type contains ``Any``, or that are not checked by
142+
mypy (ie.: contains no parameter *and* no return type, see
143+
[python/mypy#4409](https://github.com/python/mypy/issues/4409),
144+
[python/mypy#10149](https://github.com/python/mypy/issues/10149) and
145+
[python/mypy#6646](https://github.com/python/mypy/issues/6646) ).
146+
147+
Instead of typing an explicit return type annotation as
148+
``Generator[..., None, None]``, we'll prefer using an ``Iterator`` as it is more
149+
concise and conceptually easier to deal with. Returning a ``Generator`` with no
150+
``yield`` type or ``send`` type can sometimes be considered as exposing
151+
implementation details. See
152+
[Y058](https://github.com/PyCQA/flake8-pyi/blob/main/ERRORCODES.md).

0 commit comments

Comments
 (0)