-
Notifications
You must be signed in to change notification settings - Fork 179
Type annotations #151
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Type annotations #151
Conversation
Looking good to me. I think it'll be great to get mypy in tox. |
Done. I've added both mypy and flake8 into tox config. Keep in mind that mypy now produces errors, I propose to fix them later. Also, for that reason, I don't run mypy on CI just yet. Additionally, I've unlocked the flake8 version constraint since CI always installs the latest release. |
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.
Very nice!
@@ -1,3 +1,4 @@ | |||
mock==1.0.1 | |||
nose==1.2.1 | |||
flake8==1.7.0 | |||
flake8 | |||
mypy==0.910 |
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.
Upgrade?
@@ -34,15 +44,21 @@ def timing(self, stat, delta, rate=1): | |||
delta = delta.total_seconds() * 1000. | |||
self._send_stat(stat, '%0.6f|ms' % delta, rate) | |||
|
|||
def incr(self, stat, count=1, rate=1): | |||
def incr(self, stat: str, count: int = 1, rate: float = 1) -> None: |
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.
I think this might accept non-integer values, at least, there's a test for that case
Line 152 in aed9504
cl.incr('foo', 1.2) |
def incr(self, stat: str, count: int = 1, rate: float = 1) -> None: | |
def incr(self, stat: str, count: float = 1, rate: float = 1) -> None: |
There are now merge conflicts, and I don't work with pystatsd anymore. If anyone is interested in the proposed changes, feel free to pick up the changes from this PR and send a new PR based on it. I'll leave the branch and the fork alive if anyone is interested. |
There are a few type errors that require carefully changing the code. I decided to not do any drastic code changes just yet. So, adding mypy on CI is something to do in a follow-up PR.