Skip to content

docs: bring public docstrings up to NumPy completeness (#91)#100

Merged
Faerkeren merged 1 commit into
mainfrom
docs/issue-91-numpy-docstrings
May 27, 2026
Merged

docs: bring public docstrings up to NumPy completeness (#91)#100
Faerkeren merged 1 commit into
mainfrom
docs/issue-91-numpy-docstrings

Conversation

@Faerkeren
Copy link
Copy Markdown
Contributor

Closes #91.

Issue validity

Valid and actionable. mkdocs.yml configures mkdocstrings with docstring_style: numpy, so reference docs quality depends directly on public docstrings. An audit confirmed several public APIs still had one-line docstrings missing Returns / Parameters / Raises / Notes sections, particularly:

  • HAClient lifecycle methods and accessor properties
  • Domain action shortcuts that wrap _call_service (no-arg on / off / toggle / play / pause / open / close / ...)
  • Properties that perform non-obvious coercion or live computation
  • Per-domain edge cases (e.g. Light.set_kelvin not clamping; Scene.name mapping to friendly_name)

Fix

Expanded docstrings across the public API surface to NumPy completeness:

  • src/haclient/api.pyHAClient.__aenter__, __aexit__, connect, close, and every public property (config, base_url, connection, events, services, state, domains, loop).
  • Domain action shortcuts (switch, cover, lock, fan, humidifier, valve, media_player, scene, timer) — each now documents the underlying HA service invoked and the CommandError / HTTPError / TimeoutError / ConnectionClosedError surface, plus capability-gating behavior where relevant (e.g. MediaPlayer.next does not pre-check NowPlaying.next).
  • Properties with non-trivial semanticsLight.rgb_color, Switch.is_on, Scene.name / icon, Timer.duration / remaining / finishes_at / time_remaining / persistent, MediaPlayer.now_playing.
  • Light.set_kelvin — documents that the value is forwarded verbatim (no min/max clamping) and that out-of-range values surface as CommandError from HA.
  • Scene.delete — documents that it only works for runtime-created scenes and that the local entity is not removed from the registry.
  • Timer.cancel / finish — documents the auto-cleanup side effect for ephemeral timers.

No behavior changes; documentation only.

Checks run

  • ruff check src tests — passed
  • ruff format --check src tests — passed (60 files already formatted)
  • mypy src — passed (no issues in 38 source files)
  • pytest tests/ --cov=haclient --cov-fail-under=95329 passed, 97.19% coverage

Expand thin one-line docstrings across public APIs to include the
NumPy sections users and the mkdocstrings reference rely on.

- api.py: HAClient lifecycle methods (connect/close/__aenter__/__aexit__)
  and accessor properties now document side effects, return shapes,
  and propagated exceptions.
- Domain action shortcuts (switch.on/off/toggle, cover.open/close/stop/
  toggle, lock.lock/unlock, fan.on/off/toggle, humidifier.on/off/toggle,
  valve.open/close/toggle, media_player.play/pause/play_pause/stop/next/
  previous/power_on/power_off, timer.pause/cancel/finish, scene.delete,
  FavoriteItem.play) now document the underlying HA service and the
  CommandError / HTTPError / TimeoutError / ConnectionClosedError
  surface, including the lack of capability gating where relevant.
- Properties with non-obvious semantics (Light.rgb_color, Switch.is_on,
  Scene.name/icon, Timer.duration/remaining/finishes_at/time_remaining/
  persistent, MediaPlayer.now_playing) now document data shape and
  computation/coercion behavior.
- Light.set_kelvin documents that the value is forwarded verbatim
  (no min/max clamping) and that out-of-range values surface as
  CommandError from HA.
@Faerkeren Faerkeren merged commit a5c10de into main May 27, 2026
12 checks passed
@Faerkeren Faerkeren deleted the docs/issue-91-numpy-docstrings branch May 27, 2026 18:41
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.

Bring public docstrings up to NumPy completeness

1 participant