-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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 Home Assistant PEP-561 compatible #106715
Conversation
I would like some feedback/agreement/disagreement from multiple core members before we merge this one. /CC @cdce8p as our typing guru |
I think we should type the following entity components strict first:
Otherwise it sounds ok and all the common parts that are used seem to be strictly typed. |
Ok, so started doing these entity components, and this was pretty helpful. However, while doing this, I noticed how many core parts aren't typed actually. For example, many helpers don't pass strict typing, same for util, backports, data entry flows, config entries, and more... I'm going to close this for now and going to consider a typeshed route instead. ../Frenck |
Hmm, usually I'm all for adding it. Even considered it myself a while ago. However, I'm not sure the project is well suited for it. As you already noticed, it's quite difficult for us to fully / strictly type everything nevertheless just the important stuff. My go to example is the config flow. Dynamically calling methods ( That's not to say that Where does that leave us? You mentioned My personal recommendations for custom integration developer would be to
Just some of my thoughts. --
Do you have any particular examples? I might be able to take a look. |
Proposed change
Mark the
homeassistant
package as PEP-561 compatible. This allows custom integrations to runmypy
checks on references tohomeassistant
core components.This allows custom integrations to add more quality insurance to their integrations.
Also attempted in #28866, but back in 2019, we weren't that greatly typed yet; now we are.
There is one catch, as the PEP dictates:
This is not the case, as many integrations have been excluded from typing. However, in reality, that isn't a practical issue for
mypy
orpyright
. Additionally, those untyped integrations, are not part of stuff other integrations build upon. Therefore, I think the gain is still relevant for upstream custom integrators.As an alternative to this PR, a type stub/shed could be created.
Ref: https://www.python.org/dev/peps/pep-0561/
To-do
Ensure our entity components are strictly typed:
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: