Skip to content
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,8 @@ What is mypy?
-------------

Mypy is an optional static type checker for Python. You can add type
hints to your Python programs using the standard for type
annotations introduced in Python 3.5 ([PEP 484](https://www.python.org/dev/peps/pep-0484/)), and use mypy to
type check them statically. Find bugs in your programs without even
running them!

The type annotation standard has also been backported to earlier
Python 3.x versions. Mypy supports Python 3.3 and later.
XML based reports do not work on Python 3.3 and 3.4 on Windows.

For Python 2.7, you can add annotations as comments (this is also
specified in [PEP 484](https://www.python.org/dev/peps/pep-0484/)).
hints to your Python programs, and use mypy to type check them statically.
Find bugs in your programs without even running them!

You can mix dynamic and static typing in your programs. You can always
fall back to dynamic typing when static typing is not convenient, such
Expand All @@ -52,11 +43,19 @@ def fib(n: int) -> Iterator[int]:
yield a
a, b = b, a + b
```
This example uses Python 3 style of the standard type annotations, defined in [PEP 484](https://www.python.org/dev/peps/pep-0484/).

For Python 2.7, the standard annotations are written as comments:
```python
def reverse(s): # type: str -> str

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the # type comment on a separate line (it's the more common style).

return s[::-1]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use a slightly less trivial example? Like is_palindrome(s) that returns s == s[::-1]?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! :)
I tried to find something like that and all I came up with was reverse :(

```

See [the documentation](http://mypy.readthedocs.io/en/stable/introduction.html) for more examples.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the docs link should come before the Python 2 example. There should be a separate deep link for the Python 2 docs. The PEP 484 link should be moved back into the "What is mypy" section above (but without mention of Python 3.5).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to keep it fluent, while staying clear and concise. I gave it another try.

Maybe there can be some explanation about PEP-484 in a dedicated section.


Mypy is in development; some features are missing and there are bugs.
See 'Development status' below.


Requirements
------------

Expand Down