@@ -25,23 +25,15 @@ What is mypy?
25
25
-------------
26
26
27
27
Mypy is an optional static type checker for Python. You can add type
28
- hints to your Python programs using the standard for type
29
- annotations introduced in Python 3.5 ([ PEP 484] ( https://www.python.org/dev/peps/pep-0484/ ) ), and use mypy to
30
- type check them statically. Find bugs in your programs without even
31
- running them!
32
-
33
- The type annotation standard has also been backported to earlier
34
- Python 3.x versions. Mypy supports Python 3.3 and later.
35
- XML based reports do not work on Python 3.3 and 3.4 on Windows.
36
-
37
- For Python 2.7, you can add annotations as comments (this is also
38
- specified in [ PEP 484] ( https://www.python.org/dev/peps/pep-0484/ ) ).
28
+ hints ([ PEP 484] ( https://www.python.org/dev/peps/pep-0484/ ) ) to your
29
+ Python programs, and use mypy to type check them statically.
30
+ Find bugs in your programs without even running them!
39
31
40
32
You can mix dynamic and static typing in your programs. You can always
41
33
fall back to dynamic typing when static typing is not convenient, such
42
34
as for legacy code.
43
35
44
- Here is a small example to whet your appetite:
36
+ Here is a small example to whet your appetite (Python 3) :
45
37
46
38
``` python
47
39
from typing import Iterator
@@ -52,11 +44,20 @@ def fib(n: int) -> Iterator[int]:
52
44
yield a
53
45
a, b = b, a + b
54
46
```
47
+ See [ the documentation] ( http://mypy.readthedocs.io/en/stable/introduction.html ) for more examples.
48
+
49
+ For Python 2.7, the standard annotations are written as comments:
50
+ ``` python
51
+ def is_palindrome (s ):
52
+ # type: ( str ) -> bool
53
+ return s == s[::- 1 ]
54
+ ```
55
+
56
+ See [ the documentation for Python 2 support] ( http://mypy.readthedocs.io/en/latest/python2.html ) .
55
57
56
58
Mypy is in development; some features are missing and there are bugs.
57
59
See 'Development status' below.
58
60
59
-
60
61
Requirements
61
62
------------
62
63
@@ -157,9 +158,6 @@ In Windows, the script is generally installed in
157
158
158
159
C:\>\Python34\python \Python34\Scripts\mypy PROGRAM
159
160
160
- If you are on Windows using Python 3.3 or 3.4, and would like to use XML reports
161
- download LXML from [ PyPi] ( https://pypi.python.org/pypi/lxml ) .
162
-
163
161
### Working with ` virtualenv `
164
162
165
163
If you are using [ ` virtualenv ` ] ( https://virtualenv.pypa.io/en/stable/ ) ,
0 commit comments