@@ -43,13 +43,14 @@ should ignore it and simply treat the type as ``T``. Unlike the
4343``no_type_check `` functionality that currently exists in the ``typing ``
4444module which completely disables typechecking annotations on a function
4545or a class, the ``Annotated `` type allows for both static typechecking
46- of ``T `` (e.g., via mypy [mypy ]_ or Pyre [pyre ]_, which can safely ignore ``x ``)
46+ of ``T `` (e.g., via `mypy <mypy _>`_ or `Pyre <pyre _>`_,
47+ which can safely ignore ``x ``)
4748together with runtime access to ``x `` within a specific application. The
4849introduction of this type would address a diverse set of use cases of interest
4950to the broader Python community.
5051
51- This was originally brought up as issue 600 [ issue-600 ] _ in the typing github
52- and then discussed in Python ideas [ python-ideas ] _.
52+ This was originally brought up as ` issue 600 < issue-600 _>` _ in the typing github
53+ and then discussed in ` Python ideas < python-ideas _>` _.
5354
5455Motivating examples
5556-------------------
@@ -81,21 +82,21 @@ Lowering barriers to developing new typing constructs
8182~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8283
8384Typically when adding a new type, a developer need to upstream that type to the
84- typing module and change mypy, PyCharm [ pycharm ] _, Pyre, pytype [ pytype ] _,
85+ typing module and change mypy, ` PyCharm < pycharm _>` _, Pyre, ` pytype < pytype _>` _,
8586etc...
8687This is particularly important when working on open-source code that
8788makes use of these types, seeing as the code would not be immediately
8889transportable to other developers' tools without additional logic. As a result,
8990there is a high cost to developing and trying out new types in a codebase.
9091Ideally, authors should be able to introduce new types in a manner that allows
91- for graceful degradation (e.g.: when clients do not have a custom mypy plugin
92- [ mypy-plugin ] _), which would lower the barrier to development and ensure some
92+ for graceful degradation (e.g.: when clients do not have a custom ` mypy plugin
93+ < mypy-plugin_> ` _), which would lower the barrier to development and ensure some
9394degree of backward compatibility.
9495
95- For example, suppose that an author wanted to add support for tagged unions
96- [ tagged-union ] _ to Python. One way to accomplish would be to annotate
97- `` TypedDict `` [ typed-dict ]_ in Python such that only one field is allowed to be
98- set::
96+ For example, suppose that an author wanted to add support for ` tagged unions
97+ < tagged-union_> ` _ to Python. One way to accomplish would be to ` annotate
98+ <typed-dict_> `_ `` TypedDict `` in Python such that only one field is allowed
99+ to be set::
99100
100101 Currency = Annotated[
101102 TypedDict('Currency', {'dollars': float, 'pounds': float}, total=False),
@@ -236,7 +237,7 @@ cause ``Annotated`` to not integrate cleanly with the other typing annotations:
236237* ``Annotated `` cannot infer the decorated type. You could imagine that
237238 ``Annotated[..., Immutable] `` could be used to mark a value as immutable
238239 while still inferring its type. Typing does not support using the
239- inferred type anywhere else [ issue-276 ] _; it's best to not add this as a
240+ inferred type ` anywhere else < issue-276 _>` _; it's best to not add this as a
240241 special case.
241242
242243* Using ``(Type, Ann1, Ann2, ...) `` instead of
@@ -253,40 +254,34 @@ This feature was left out to keep the design simple:
253254 little benefit.
254255
255256
256- References
257- ----------
258-
259- .. [issue-600 ]
257+ .. _issue-600 :
260258 https://github.com/python/typing/issues/600
261259
262- .. [ python -ideas]
260+ .. _ python -ideas:
263261 https://mail.python.org/pipermail/python-ideas/2019-January/054908.html
264262
265- .. [struct-doc ]
266- https://docs.python.org/3/library/struct.html#examples
267-
268- .. [mypy ]
263+ .. _mypy :
269264 http://www.mypy-lang.org/
270265
271- .. [ pyre ]
266+ .. _ pyre :
272267 https://pyre-check.org/
273268
274- .. [ pycharm ]
269+ .. _ pycharm :
275270 https://www.jetbrains.com/pycharm/
276271
277- .. [ pytype ]
272+ .. _ pytype :
278273 https://github.com/google/pytype
279274
280- .. [ mypy -plugin]
275+ .. _ mypy -plugin:
281276 https://github.com/python/mypy_extensions
282277
283- .. [ tagged -union]
278+ .. _ tagged -union:
284279 https://en.wikipedia.org/wiki/Tagged_union
285280
286- .. [ typed -dict]
281+ .. _ typed -dict:
287282 https://mypy.readthedocs.io/en/latest/more_types.html#typeddict
288283
289- .. [ issue -276]
284+ .. _ issue -276:
290285 https://github.com/python/typing/issues/276
291286
292287Copyright
0 commit comments