Skip to content

Commit e74d960

Browse files
authored
writing_stubs: add examples of allowed and disallowed language features (#1837)
1 parent 0b4e1aa commit e74d960

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/guides/writing_stubs.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,14 @@ Language Features
579579
-----------------
580580

581581
Use the latest language features available, even for stubs targeting older
582-
Python versions. Do not use quotes around forward references and do not use
583-
``__future__`` imports. See :ref:`stub-file-syntax` for more information.
582+
Python versions. For example, Python 3.7 added the ``async`` keyword (see
583+
:pep:`492`). Stubs should use it to mark coroutines, even if the implementation
584+
still uses the ``@coroutine`` decorator. On the other hand, the ``type`` soft
585+
keyword from :pep:`695`, introduced in Python 3.12, should not be used in stubs
586+
until Python 3.11 reaches end-of-life in October 2027.
587+
588+
Do not use quotes around forward references and do not use ``__future__``
589+
imports. See :ref:`stub-file-syntax` for more information.
584590

585591
Yes::
586592

0 commit comments

Comments
 (0)