Uh oh!
There was an error while loading. Please reload this page.
README.md: rearrange first paragraph to be more friendly - #4002
Conversation
| Mypy is in development; some features are missing and there are bugs. | ||
| See 'Development status' below. | ||
| Annotations |
gvanrossum
commented
Sep 25, 2017
Can you move the bullet about the xml reporter elsewhere? It's a distraction at this point. I'd also fold the discussion of supported Python 3 versions into one sentence. |
elazarg
commented
Sep 25, 2017
I tried something slightly different - demonstration for python 2 too. I'm not sure this is a good idea, but I couldn't find the right way to phrase it. |
gvanrossum
left a comment
There was a problem hiding this comment.
I'm not keen on explicit annotations for local variables, since these are correctly inferred from the initializer. Rest LG.
| If you are on Windows using Python 3.3 or 3.4, and would like to use XML reports | ||
| download LXML from [PyPi](https://pypi.python.org/pypi/lxml). | ||
| download LXML from [PyPi](https://pypi.python.org/pypi/lxml). | ||
| XML based reports do not work on Python 3.3 and 3.4 on Windows. |
There was a problem hiding this comment.
They do work, but only if you have LXML installed. The last sentence can be deleted.
elazarg
commented
Sep 25, 2017
So should I just remove the annotations? I think it's valuable to be aware of the way to annotate variables, since most people will not read the PEP. If the example will return a list we'll have both: fromtypingimportListdeffib(n: int) ->List[int]:
a, b=0, 1result: List[int] = []
whilea<n:
result.append(a)
a, b=b, a+breturnresult |
ilevkivskyi
commented
Sep 25, 2017
I am not sure here, people will most likely not read read the PEP, but we should make them read the docs (at least to some extent). |
gvanrossum
commented
Sep 25, 2017
via email
The readme is not the place for this. It should point people to the real
docs, in particular an introduction, right after the example. …On Sep 25, 2017 1:03 PM, "Elazar Gershuni" ***@***.***> wrote:
So should I just remove the annotations? I think it's valuable to be aware
of the way to annotate variables, since most people will not read the PEP.
If the example will return a list we'll have both:
from typing import List
def fib(n: int) -> List[int]:
a, b = 0, 1
result: List[int] = []
while a < n:
result.append(a)
a, b = b, a + b
return result
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4002 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACwrMvSLCZYEsucXPc9fqi0HZLOvEL3_ks5smAcIgaJpZM4PiP6n>
.
|
Smaller example for python2; only show the difference
| @@ -168,8 +168,7 @@ In Windows, the script is generally installed in | |||
| C:\>\Python34\python \Python34\Scripts\mypy PROGRAM | |||
| If you are on Windows using Python 3.3 or 3.4, and would like to use XML reports | |||
There was a problem hiding this comment.
If #4007 gets merged before this, this sentence can be removed, as there are wheels for all Python versions on Windows now, and installing via test-requirements will "just work".
elazarg
commented
Sep 26, 2017
Is this OK now? I tried to make it shorter so the first part will fit in a laptop screen. |
gvanrossum
left a comment
There was a problem hiding this comment.
Sorry, I had pending comments that I forgot to send.
| For Python 2.7, the standard annotations are written as comments: | ||
| ```python | ||
| def reverse(s): # type: str -> str |
There was a problem hiding this comment.
Please put the # type comment on a separate line (it's the more common style).
| return s[::-1] | ||
| ``` | ||
| See [the documentation](http://mypy.readthedocs.io/en/stable/introduction.html) for more examples. |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
| For Python 2.7, the standard annotations are written as comments: | ||
| ```python | ||
| def reverse(s): | ||
| # type: str -> str |
There was a problem hiding this comment.
This should be # type: (str) -> str (note parentheses), otherwise it is syntax error in type comment.
| 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 ([PEP 484](https://www.python.org/dev/peps/pep-0484/)) to your Python programs, and use mypy to type check them statically. |
There was a problem hiding this comment.
Not super-important, but could you please make lines in your diff 79 chars?
There was a problem hiding this comment.
Sorry. I will try to keep it in mind.
| ```python | ||
| def reverse(s): | ||
| # type: str -> str | ||
| return s[::-1] |
There was a problem hiding this comment.
Maybe use a slightly less trivial example? Like is_palindrome(s) that returns s == s[::-1]?
There was a problem hiding this comment.
Nice! :)
I tried to find something like that and all I came up with was reverse :(
The discussion of different annotations need not be the first thing the reader see.