-
Notifications
You must be signed in to change notification settings - Fork 335
Enable mypy in CI #1101
Enable mypy in CI #1101
Conversation
This pull request introduces 1 alert when merging 9656b42 into 04fefd8 - view on LGTM.com new alerts:
|
This pull request fixes 1 alert when merging fe7547d into 04fefd8 - view on LGTM.com fixed alerts:
|
Thanks for working in this for us! I've added @bmerry as a reviewer, as he's done a lot of work to get our static typing up to snuff. |
This pull request fixes 1 alert when merging f8d83df into 04fefd8 - view on LGTM.com fixed alerts:
|
@@ -0,0 +1,30 @@ | |||
[mypy] |
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.
Commented out things are to be enabled in future PRs.
Codecov Report
@@ Coverage Diff @@
## master #1101 +/- ##
==========================================
- Coverage 89.22% 89.14% -0.09%
==========================================
Files 21 21
Lines 6823 6871 +48
Branches 653 658 +5
==========================================
+ Hits 6088 6125 +37
- Misses 567 580 +13
+ Partials 168 166 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This pull request fixes 1 alert when merging ed06034 into 04fefd8 - view on LGTM.com fixed alerts:
|
This pull request fixes 1 alert when merging bea076b into 04fefd8 - view on LGTM.com fixed alerts:
|
This pull request fixes 1 alert when merging 8617538 into 04fefd8 - view on LGTM.com fixed alerts:
|
client.py is almost done, will probably push it tomorrow. Could one of you do a quick review of my PR to upgrade aioredis in aiohttp-session? |
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'm afraid I'm not going to have time to review this, sorry.
This pull request fixes 1 alert when merging e8e21a4 into 9d71774 - view on LGTM.com fixed alerts:
|
This pull request introduces 1 alert and fixes 1 when merging e7d456d into 9d71774 - view on LGTM.com new alerts:
fixed alerts:
|
This pull request fixes 1 alert when merging 250e6ed into 9d71774 - view on LGTM.com fixed alerts:
|
This pull request fixes 1 alert when merging ae2dfa6 into 9d71774 - view on LGTM.com fixed alerts:
|
This pull request fixes 1 alert when merging f613529 into 9d71774 - view on LGTM.com fixed alerts:
|
This pull request fixes 1 alert when merging f5a8e80 into 9d71774 - view on LGTM.com fixed alerts:
|
I wouldn't worry too much about reviewing all the type annotations. Any mistakes should become apparent and be fixed as we expand the typing coverage. If someone can review the minor runtime changes, that's probably all that's really needed before merging this. I'll wait until you're ready to proceed before making any more progress. |
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.
Looks fine to me. Most of this code is just typing, but there are some stuff that isn't; for example, the "cast"-ing is something I'm not really happy with. Or an assertion statement that should instead be an if condition.
Besides that, I think this PR doesn't affect the code base too much.
Though, when it comes to maintenance and PR adding, I do think the CI could be non-blocking like codecov. It'll obviously break people's mypy every so often, but I guess it's a balancing act.
aioredis/connection.py
Outdated
class Sentinel(enum.Enum): | ||
sentinel = object() |
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.
Why is this enum.Enum
needed? And can you prepend an underscore to Sentinel
?
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.
Sentinels are a little tricky to type. It seems that an enum is the best approach to use:
https://stackoverflow.com/a/60605919
Note that casting is just typing. At runtime it just returns the argument unchanged.
I think the problem is that the easiest time to fix a typing error is when you make the change. i.e. The author of a PR has the best knowledge of that code during the period of working on that PR. |
I was just thinking it as an extra, "unnecessary" operation in terms of actual execution of commands.
That's true. @abrookins Can you provide a review of in general 1. should we still include the mypy CI (I approve) and 2. any other concerns? I wouldn't bother reviewing the entire thing since we can just change annotations over time if there is something incorrect. |
This pull request fixes 1 alert when merging 6180fa8 into 4fbee2e - view on LGTM.com fixed alerts:
|
Thanks a lot @Dreamsorcerer ! |
Oh man, I'm trying to add the examples to the type checking and aioredis doesn't lend itself to static type checking very well. The examples use |
Initial mypy config and type fixes to get it enabled in CI.
Starting on this while I'm waiting on some other things.