-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add type annotations #19
Conversation
Big 👍 from me on this. Is it python2 that restricts us from using the annotation format found here? https://docs.python.org/3/library/typing.html |
Mainly that, yes, but pyannotate does not support py3-style annotations yet so we'd have to add them all manually if we wanted to go that way. Are you planning to drop 2.7 support here as well? |
445f149
to
2b8374a
Compare
2b8374a
to
3c58f5f
Compare
@pipermerriam I don't seem to have rights to ask for a review on this repo, so doing that by pinging you here |
Yes, my plan is to drop 2.7 support across all of the tooling I maintain by the end of Q1 2018. |
@@ -1,6 +1,7 @@ | |||
from __future__ import absolute_import | |||
|
|||
import os | |||
from typing import Optional # noqa: F401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this is due to the use of this within the type annotation comments. Odd but also makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, yes
eth_keys/backends/native/ecdsa.py
Outdated
@@ -3,6 +3,7 @@ | |||
""" | |||
import hashlib | |||
import hmac | |||
from typing import (Callable, Optional, Tuple, Union) # noqa: F401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Union doesn't appear to be used here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, removed
Also adds a new tox testenv that uses mypy to perform static type checks
3c58f5f
to
ee29572
Compare
Drop py3.5, add py3.7
This branch includes a pytest fixture that uses pyannotate to dump a json file with type information.
Once you feed that to pyannotate it will generate the type annotation comments seen in the diff here, although I had to modify some of them for various reasons (that is expected).
With those comments we can use mypy to perform static type checking, like this: