-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Mark homeassistant PEP 561 compatible #28866
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.
I don't think we can do this yet. PEP 561 says about the marker file:
if a top-level package includes it, all its sub-packages MUST support type checking as well.
A lot of our stuff isn't type checked at all yet, at least those parts I think don't qualify. And a lot have inline mypy exclusions, I suppose those don't qualify either.
https://www.python.org/dev/peps/pep-0561/#packaging-type-information
We run mypy internally on all of home assistant. So at least it doesn't fail. I'm not too vested in this though. |
I'm fairly certain (but haven't tested) that if we mark ourselves as typed but we actually are not typed everywhere, things will get noticeably worse for custom components and other "external" users that happen to use the parts that are not type hinted. An example: ruamel.yaml does exactly this, marks itself as PEP 561 compatible but lacks severely in type hints. Because of that we have to add some |
So at the minimum I'd say someone needs to test how type checks behave if we have that marker, and an external thing uses some of our untyped functionality and runs type checks with the same strict config as we do. The original report says the change is tested, but is it tested against this use case? |
It's just tested against my custom component. It is not set especially strict thought. |
The problem is that mypy complains whenever home assistant component are imported that it can't be found. since it consider the lib untyped. So it reduced warnings by about 30 in the custom component. |
Is your component using any of our untyped functions? |
I'm unsure. The component isn't fully typed either. https://github.com/elupus/hass_nibe I will try to do some more verification. |
@elupus any updates on this PR? :) |
Sorry no. Not had time to look at it. |
No worries, I was just curious. |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Description:
Mark homeassistant package as pep 561 compatible https://www.python.org/dev/peps/pep-0561/. This allow custom components to run mypy checks on references to homeassistant components.
Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
python3 -m script.hassfest
.requirements_all.txt
by runningpython3 -m script.gen_requirements_all
..coveragerc
.If the code does not interact with devices: