@@ -38,7 +38,8 @@ Here is a small example to whet your appetite:
38
38
from typing import Iterator
39
39
40
40
def fib (n : int ) -> Iterator[int ]:
41
- a, b = 0 , 1
41
+ a: int = 0
42
+ b: int = 1
42
43
while a < n:
43
44
yield a
44
45
a, b = b, a + b
@@ -49,14 +50,21 @@ See 'Development status' below.
49
50
50
51
Annotations
51
52
-----------
52
- You can add type hints to your Python programs using the standard for type
53
- annotations introduced in Python 3.5 ([ PEP 484] ( https://www.python.org/dev/peps/pep-0484/ ) ).
54
- The type annotation standard has also been backported to earlier
55
- Python 3.x versions. Mypy supports Python 3.3 and later.
56
- XML based reports do not work on Python 3.3 and 3.4 on Windows.
53
+ For Python 3, you can add type hints to your Python programs using the standard for type
54
+ annotations ([ PEP 484] ( https://www.python.org/dev/peps/pep-0484/ ) ).
57
55
58
56
For Python 2.7, you can add annotations as comments (this is also
59
- specified in [ PEP 484] ( https://www.python.org/dev/peps/pep-0484/ ) ).
57
+ specified in [ PEP 484] ( https://www.python.org/dev/peps/pep-0484/ ) ):
58
+ ``` python
59
+ from typing import Iterator
60
+
61
+ def fib (n ): # type: int -> Iterator [ int ]
62
+ a = 0 # type: int
63
+ b = 1 # type: int
64
+ while a < n:
65
+ yield a
66
+ a, b = b, a + b
67
+ ```
60
68
61
69
62
70
Requirements
@@ -160,7 +168,8 @@ In Windows, the script is generally installed in
160
168
C:\>\Python34\python \Python34\Scripts\mypy PROGRAM
161
169
162
170
If you are on Windows using Python 3.3 or 3.4, and would like to use XML reports
163
- download LXML from [ PyPi] ( https://pypi.python.org/pypi/lxml ) .
171
+ download LXML from [ PyPi] ( https://pypi.python.org/pypi/lxml ) .
172
+ XML based reports do not work on Python 3.3 and 3.4 on Windows.
164
173
165
174
### Working with ` virtualenv `
166
175
0 commit comments