@@ -275,24 +275,25 @@ the built-in collections or those from :py:mod:`collections.abc`
275275 y: dict[int , str ]
276276 z: Sequence[str ] = x
277277
278+ There is limited support for using this syntax in Python 3.7 and later as well.
278279If you use ``from __future__ import annotations ``, mypy will understand this
279- syntax in Python 3.7 and later. However, since this will not be supported by the
280- Python interpreter at runtime, make sure you're aware of the caveats mentioned
281- in the notes at :ref: `future annotations import<future-annotations> `.
280+ syntax in annotations. However, since this will not be supported by the Python
281+ interpreter at runtime, make sure you're aware of the caveats mentioned in the
282+ notes at :ref: `future annotations import<future-annotations> `.
282283
283- Using new syntax
284- ----------------
284+ Using X | Y syntax for Unions
285+ -----------------------------
285286
286287Starting with Python 3.10 (:pep: `604 `), you can spell union types as ``x: int |
287288str ``, instead of ``x: typing.Union[int, str] ``.
288289
290+ There is limited support for using this syntax in Python 3.7 and later as well.
289291If you use ``from __future__ import annotations ``, mypy will understand this
290- syntax in Python 3.7 and later. However, since this will not be supported by the
291- Python interpreter at runtime (if evaluated, ``int | str `` will raise
292- ``TypeError: unsupported operand type(s) for |: 'type' and 'type' ``), make sure
293- you're aware of the caveats mentioned in the notes at :ref: `future annotations
294- import<future-annotations>`. You can also use the new syntax in string literal
295- types or type comments.
292+ syntax in annotations, string literal types, type comments and stub files.
293+ However, since this will not be supported by the Python interpreter at runtime
294+ (if evaluated, ``int | str `` will raise ``TypeError: unsupported operand type(s)
295+ for |: 'type' and 'type' ``), make sure you're aware of the caveats mentioned in
296+ the notes at :ref: `future annotations import<future-annotations> `.
296297
297298Using new additions to the typing module
298299----------------------------------------
0 commit comments