Skip to content

fix: correct feed fields return type and re-export public names - #4

Merged
alexandrecuer merged 2 commits into
Open-Building-Management:mainfrom
davidski:fix/feed-fields-type
Nov 16, 2026
Merged

alexandrecuer merged 2 commits into
Open-Building-Management:mainfrom
davidski:fix/feed-fields-type

Conversation

@davidski

Copy link
Copy Markdown
Contributor

Summary

Two typing fixes on top of #3, found by type-checking a consumer against the package with mypy --strict.

 pyemoncms/
 ├── __init__.py
+│     __all__ = ["EmoncmsAuthError", "EmoncmsClient", "EmoncmsConnectionError", "EmoncmsError"]
 └── emoncms_client.py
-      async_get_feed_fields(...) -> list[Any] | None
+      async_get_feed_fields(...) -> dict[str, Any] | None
  • feed/aget.json returns one feed as a JSON object (Feed::get() returns the feed row plus time and value), so the return type is a dict, not a list. My mistake in feat: ship py.typed and pass mypy --strict #3.
  • Without __all__, strict type checkers (mypy's no_implicit_reexport, which HA enables) reject from pyemoncms import EmoncmsClient.

Evidence

Consumer script:

from pyemoncms import EmoncmsClient

async def f(c: EmoncmsClient) -> None:
    fields = await c.async_get_feed_fields(1)
    if fields:
        print(fields["name"])
  • Before (main):
    mypy --strict consumer.py
      error: Module "pyemoncms" does not explicitly export attribute "EmoncmsClient"
      error: No overload variant of "__getitem__" of "list" matches argument type "str"
    Found 2 errors in 1 file
    
    After:
    mypy --strict consumer.py pyemoncms  -> Success: no issues found in 3 source files
    
  • pylint 10/10.

Merge Danger

Door: two-way

Blast Radius: none

  • Type hints only; no runtime behavior changes.

@alexandrecuer
alexandrecuer merged commit 6ee60e9 into Open-Building-Management:main Nov 16, 2026
4 checks passed
@alexandrecuer alexandrecuer added this to the v0.1.4 milestone Nov 16, 2026
@alexandrecuer

Copy link
Copy Markdown
Contributor

@davidski : I will produce the release tomorrow, just tell me if you have something else in mind

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants