@@ -46,7 +46,7 @@ Essentially, such a type checker acts as a very powerful linter.
46
46
a similar checker at run time for Design By Contract enforcement or
47
47
JIT optimization, those tools are not yet as mature.)
48
48
49
- The proposal is strongly inspired by mypy [mypy] _. For example, the
49
+ The proposal is strongly inspired by ` mypy <mypy_>` _. For example, the
50
50
type "sequence of integers" can be written as ``Sequence[int]``. The
51
51
square brackets mean that no new syntax needs to be added to the
52
52
language. The example here uses a custom type ``Sequence``, imported
@@ -68,8 +68,8 @@ Rationale and Goals
68
68
69
69
:pep:`3107` added support for arbitrary annotations on parts of a
70
70
function definition. Although no meaning was assigned to annotations
71
- then, there has always been an implicit goal to use them for type
72
- hinting [ gvr-artima] _, which is listed as the first possible use case
71
+ then, there has always been an ` implicit goal to use them for type
72
+ hinting < gvr-artima_>` _, which is listed as the first possible use case
73
73
in said PEP.
74
74
75
75
This PEP aims to provide a standard syntax for type annotations,
@@ -760,8 +760,8 @@ to the list, which would violate the variable's type in the caller.
760
760
It turns out such an argument acts *contravariantly*, whereas the
761
761
intuitive answer (which is correct in case the function doesn't mutate
762
762
its argument!) requires the argument to act *covariantly*. A longer
763
- introduction to these concepts can be found on Wikipedia
764
- [ wiki-variance] _ and in :pep:`483`; here we just show how to control
763
+ introduction to these concepts can be found on ` Wikipedia
764
+ < wiki-variance_>` _ and in :pep:`483`; here we just show how to control
765
765
a type checker's behavior.
766
766
767
767
By default generic types are considered *invariant* in all type variables,
@@ -1660,7 +1660,7 @@ Additional notes on stub files:
1660
1660
exported. (This makes it easier to re-export all objects from a
1661
1661
given module that may vary by Python version.)
1662
1662
1663
- * Just like in normal Python files [importdocs] _, submodules
1663
+ * Just like in ` normal Python files <importdocs_>` _, submodules
1664
1664
automatically become exported attributes of their parent module
1665
1665
when imported. For example, if the ``spam`` package has the
1666
1666
following directory structure::
@@ -1861,8 +1861,8 @@ enabled by including a file named ``py.typed`` in the package.)
1861
1861
The Typeshed Repo
1862
1862
-----------------
1863
1863
1864
- There is a shared repository where useful stubs are being collected
1865
- [typeshed]_ . Policies regarding the stubs collected here will be
1864
+ There is a ` shared repository <typeshed_>`_ where useful stubs are being
1865
+ collected . Policies regarding the stubs collected here will be
1866
1866
decided separately and reported in the repo's documentation.
1867
1867
Note that stubs for a given package will not be included here
1868
1868
if the package owners have specifically requested that they be omitted.
@@ -2365,8 +2365,9 @@ evaluation. There are several things wrong with this idea, however.
2365
2365
is unheard of in English, and in other languages (e.g. C++) it is
2366
2366
used as a scoping operator, which is a very different beast. In
2367
2367
contrast, the single colon for type hints reads naturally -- and no
2368
- wonder, since it was carefully designed for this purpose (the idea
2369
- long predates :pep:`3107` [gvr-artima]_). It is also used in the same
2368
+ wonder, since it was carefully designed for this purpose
2369
+ (`the idea <gvr-artima_>`_
2370
+ long predates :pep:`3107`). It is also used in the same
2370
2371
fashion in other languages from Pascal to Swift.
2371
2372
2372
2373
* What would you do for return type annotations?
@@ -2397,8 +2398,8 @@ evaluation. There are several things wrong with this idea, however.
2397
2398
Other forms of new syntax
2398
2399
-------------------------
2399
2400
2400
- A few other forms of alternative syntax have been proposed, e.g. the
2401
- introduction of a ``where`` keyword [roberge]_ , and Cobra-inspired
2401
+ A few other forms of alternative syntax have been proposed, e.g. ` the
2402
+ introduction <roberge_>`_ of a ``where`` keyword, and Cobra-inspired
2402
2403
``requires`` clauses. But these all share a problem with the double
2403
2404
colon: they won't work for earlier versions of Python 3. The same
2404
2405
would apply to a new ``__future__`` import.
@@ -2433,12 +2434,12 @@ problem would that solve? It would just be procrastination.
2433
2434
PEP Development Process
2434
2435
=======================
2435
2436
2436
- A live draft for this PEP lives on GitHub [github] _. There is also an
2437
- issue tracker [issues] _, where much of the technical discussion takes
2437
+ A live draft for this PEP lives on ` GitHub <github_>` _. There is also an
2438
+ ` issue tracker <issues_>` _, where much of the technical discussion takes
2438
2439
place.
2439
2440
2440
2441
The draft on GitHub is updated regularly in small increments. The
2441
- official PEPS repo [ peps_] is (usually) only updated when a new draft
2442
+ ` official PEPS repo < peps_>`_ is (usually) only updated when a new draft
2442
2443
is posted to python-dev.
2443
2444
2444
2445
@@ -2457,55 +2458,35 @@ Anders Hejlsberg, Alok Menghrajani, Travis E. Oliphant, Joe Pamer,
2457
2458
Raoul-Gabriel Urma, and Julien Verlaguet.
2458
2459
2459
2460
2460
- References
2461
- ==========
2462
-
2463
- .. [mypy]
2461
+ .. _mypy:
2464
2462
http://mypy-lang.org
2465
2463
2466
- .. [gvr-artima]
2467
- http://www.artima.com/weblogs/viewpost.jsp?thread=85551
2468
-
2469
- .. [wiki-variance]
2470
- http://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29
2471
-
2472
- .. [typeshed]
2473
- https://github.com/python/typeshed/
2464
+ .. _gvr-artima:
2465
+ https://www.artima.com/weblogs/viewpost.jsp?thread=85551
2474
2466
2475
- .. [pyflakes]
2476
- https://github.com/pyflakes/pyflakes/
2467
+ .. _wiki-variance:
2468
+ https://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29
2477
2469
2478
- .. [pylint]
2479
- http ://www.pylint.org
2470
+ .. _typeshed:
2471
+ https ://github.com/python/typeshed
2480
2472
2481
- .. [roberge]
2482
- http ://aroberge.blogspot.com/2015/01/type-hinting-in-python-focus-on.html
2473
+ .. _roberge:
2474
+ https ://aroberge.blogspot.com/2015/01/type-hinting-in-python-focus-on.html
2483
2475
2484
- .. [github]
2476
+ .. _github:
2485
2477
https://github.com/python/typing
2486
2478
2487
- .. [issues]
2479
+ .. _issues:
2488
2480
https://github.com/python/typing/issues
2489
2481
2490
- .. [peps]
2482
+ .. _peps:
2491
2483
https://hg.python.org/peps/file/tip/pep-0484.txt
2492
2484
2493
- .. [importdocs]
2485
+ .. _importdocs:
2494
2486
https://docs.python.org/3/reference/import.html#submodules
2495
2487
2496
2488
2497
2489
Copyright
2498
2490
=========
2499
2491
2500
2492
This document has been placed in the public domain.
2501
-
2502
-
2503
-
2504
- ..
2505
- Local Variables:
2506
- mode: indented-text
2507
- indent-tabs-mode: nil
2508
- sentence-end-double-space: t
2509
- fill-column: 70
2510
- coding: utf-8
2511
- End:
0 commit comments