Skip to content

chore: improve type hints#35

Draft
baodrate wants to merge 2 commits intodahlb:mainfrom
baodrate:type-hints
Draft

chore: improve type hints#35
baodrate wants to merge 2 commits intodahlb:mainfrom
baodrate:type-hints

Conversation

@baodrate
Copy link

@baodrate baodrate commented Aug 7, 2025

Trying to debug some issues with my setup. Started by refining the type hints so that I can be a bit more confident about any changes.

  • The first commit in the PR should be exclusively type hint changes, there should be no runtime effect at all1
  • The second commit is much smaller and has some changes that affect runtime behavior (although I matched the existing behavior as close as possible)

There are a number of mypy errors remaining2 that need actual fixes in the code to resolve:


Difference (according to mypy --txt-report 2):

Module Before (308 errors) After (43 errors) Lines
src.hatch_rest_api 0.00% imprecise 0.00% imprecise 18 LOC
src.hatch_rest_api.aws_http 12.77% imprecise 8.33% imprecise 48 LOC
src.hatch_rest_api.callbacks 44.00% imprecise 3.85% imprecise 26 LOC
src.hatch_rest_api.const 20.00% imprecise 0.91% imprecise 110 LOC
src.hatch_rest_api.contentful 32.91% imprecise 11.25% imprecise 80 LOC
src.hatch_rest_api.errors 0.00% imprecise 0.00% imprecise 13 LOC
src.hatch_rest_api.hatch 30.32% imprecise 19.74% imprecise 228 LOC
src.hatch_rest_api.rest_iot 43.84% imprecise 3.10% imprecise 355 LOC
src.hatch_rest_api.rest_mini 35.56% imprecise 1.10% imprecise 91 LOC
src.hatch_rest_api.rest_plus 48.15% imprecise 0.00% imprecise 136 LOC
src.hatch_rest_api.restore_iot 49.17% imprecise 1.66% imprecise 241 LOC
src.hatch_rest_api.restore_v5 39.63% imprecise 2.70% imprecise 333 LOC
src.hatch_rest_api.shadow_client_subscriber 39.52% imprecise 28.68% imprecise 129 LOC
src.hatch_rest_api.stub 34.69% imprecise 2.04% imprecise 49 LOC
src.hatch_rest_api.types 20.63% imprecise 9.09% imprecise 165 LOC
src.hatch_rest_api.util 31.03% imprecise 28.79% imprecise 66 LOC
src.hatch_rest_api.util_bootstrap 40.89% imprecise 8.87% imprecise 293 LOC
src.hatch_rest_api.util_http 47.22% imprecise 26.83% imprecise 41 LOC
Total 37.97% imprecise 8.01% imprecise 2422 LOC

Footnotes

  1. other than the from ... import ... calls. But the package doesn't have any import-time side-effects, AFAICT

  2. with my mypy configuration that attempts to match the upstream homeassistant mypy config 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant