Skip to content

Commit eb0f945

Browse files
committed
Merge pull request #1 from JimJJewett/JimJJewett-patch-1
Clarify pep-0484 as opt-in conventions only like WSGI
2 parents 97df7b7 + c273891 commit eb0f945

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

pep-0484.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,22 @@ Resolution:
1616
Abstract
1717
========
1818

19-
This PEP introduces a standard syntax for type hints using annotations
20-
(PEP 3107) on function definitions. For example, here is a simple
21-
function whose argument and return type are declared in the
22-
annotations::
19+
PEP 3107 introduced syntax for function annotations, but the semantics
20+
were deliberately left undefined. There has now been enough 3rd party
21+
usage for static type analysis that the community would benefit from
22+
a standard vocabulary and baseline tools within the standard library.
23+
24+
This PEP introduces a provisional module to provide these standard
25+
definitions and tools, along with some conventions for situations
26+
where annotations are not available.
27+
28+
Note that this PEP still explicitly does NOT prevent other uses of
29+
annotations, nor does it require (or forbid) any particular processing
30+
of annotations, even when they conform to this specification. It
31+
simply enables better coordination, as PEP 333 did for web frameworks.
32+
33+
For example, here is a simple function whose argument and return type
34+
are declared in the annotations::
2335

2436
def greeting(name: str) -> str:
2537
return 'Hello ' + name
@@ -29,6 +41,9 @@ While these annotations are available at runtime through the usual
2941
Instead, the proposal assumes the existence of a separate off-line
3042
type checker which users can run over their source code voluntarily.
3143
Essentially, such a type checker acts as a very powerful linter.
44+
(While it would of course be possible for individual users to employ
45+
a similar checker at run time for Design By Contract enforcement or
46+
JIT optimization, those tools are not yet as mature.)
3247

3348
The proposal is strongly inspired by mypy [mypy]_. For example, the
3449
type "sequence of integers" can be written as ``Sequence[int]``. The

0 commit comments

Comments
 (0)