-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
Bring back typing check. Meanwhile just for homeassistant/*.py #14410
Conversation
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.
Cool!
return func | ||
|
||
|
||
def is_callback(func: Callable[..., Any]) -> bool: | ||
"""Check if function is safe to be called in the event loop.""" | ||
return '_hass_callback' in getattr(func, '__dict__', {}) | ||
return getattr(func, '_hass_callback', False) is True |
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.
The is True
shouldn't be needed. We will return a boolean anyway.
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.
Well, since the value could theoretically be anything, I think it's ok to check.
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.
Specifically in tests it is MagicMock
tox.ini
Outdated
deps = | ||
-r{toxinidir}/requirements_test.txt | ||
commands = | ||
mypy --ignore-missing-imports --follow-imports=skip homeassistant | ||
/bin/bash -c 'mypy --ignore-missing-imports --follow-imports=skip homeassistant/*.py' |
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.
The mypy docs recommend using silent
instead of skip
.
http://mypy.readthedocs.io/en/latest/command_line.html#follow-imports
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.
When I run with silent there's one additional error in bootstrap on line 301.
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.
Done
Nice! I was talking to Instagram here at PyCon. They have released MonkeyType. It will run your test suite and then suggest types for your code. And then FB also published Pyre, a fast type checker. We should compare performance against mypy. |
Pyre is designed to remember the result and state of the code and will normally only check changed code. If I run without forcing a recheck it takes less than a second to run again since nothing has changed.
The output is not the same as for mypy though. I get lots of these errors when running pyre:
|
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 good! Core should have a look though.
What are you're plans for more typing PRs? Do you have more in pipe already?
Description:
Bring back typing check.
Meanwhile just for
homeassistant/*.py
, rest of core to follow.Checklist:
tox
. Your PR cannot be merged unless tests pass