Skip to content

docs: modernize docstrings across the repository#1682

Open
ZeliardM wants to merge 1 commit intopython-kasa:masterfrom
ZeliardM:docs/modernize-iotbulb-docstring
Open

docs: modernize docstrings across the repository#1682
ZeliardM wants to merge 1 commit intopython-kasa:masterfrom
ZeliardM:docs/modernize-iotbulb-docstring

Conversation

@ZeliardM
Copy link
Copy Markdown
Contributor

@ZeliardM ZeliardM commented Apr 6, 2026

Summary

Comprehensive docstring cleanup across the repository — fix Sphinx cross-references, Python REPL continuation syntax, stale class names, and modernize the IotBulb docstring to use the Module.Light/Module.LightPreset interface.

Changes

Sphinx cross-references (:func::meth:):

  • iotbulb.py: update(), has_feature, turn_on/off, set_hsv/color_temp/brightness, save_preset
  • iotdevice.py, iotplug.py, iotstrip.py, iotdimmer.py: update()
  • discover.py: Discover.discover(), discover_single()

REPL continuation syntax (>>>...):

  • Fixed across 15 files: device.py, deviceconfig.py, discover.py, feature.py, module.py, tutorial.py, light.py, lightpreset.py, lighteffect.py, childsetup.py, childdevice.py, iotstrip.py
  • Uses proper ... for continuation lines inside for loops, if blocks, and multi-line function calls

Stale class references:

  • iotstrip.py: :class:\SmartPlug`:class:`IotPlug``
  • iotdimmer.py: :class:\SmartPlug`:class:`IotPlug`` (x2)
  • iotlightstrip.py: :class:\SmartBulb`:class:`IotBulb`` (x2)

Bug fixes:

  • lighteffect.py: Fixed set literal { "brightness", 50 } → dict literal {"brightness": 50}
  • tutorial.py: Suppress set_effect()/set_value() return values that leaked into xdoctest output

IotBulb docstring modernization:

  • Replaced deprecated device-level properties (bulb.brightness, bulb.is_dimmable, etc.) with Module.Light/Module.LightPreset interface
  • Updated test_readme_examples.py fixture to use KL130 with matching alias

Files changed (18)

docs/tutorial.py, kasa/device.py, kasa/deviceconfig.py, kasa/discover.py, kasa/feature.py, kasa/interfaces/childsetup.py, kasa/interfaces/light.py, kasa/interfaces/lighteffect.py, kasa/interfaces/lightpreset.py, kasa/iot/iotbulb.py, kasa/iot/iotdevice.py, kasa/iot/iotdimmer.py, kasa/iot/iotlightstrip.py, kasa/iot/iotplug.py, kasa/iot/iotstrip.py, kasa/module.py, kasa/smart/modules/childdevice.py, tests/test_readme_examples.py

Merge order

This is PR 3 of 9 in the test modernization series. Independent of test annotation PRs.

Order PR Scope
1 #1677 Tests: cleanup and fixes
2 #1681 CI: pin GitHub Actions to SHA
3 #1682 Docs: modernize docstrings
4 #1683 Tests: centralize session cleanup
5 #1684 Tests: transport type annotations
6 #1685 Tests: IoT type annotations
7 #1686 Tests: Smart type annotations
8 #1687 Tests: CLI/protocols/smartcam type annotations
9 #1688 Tests: top-level type annotations

Verification

  • All 17 docstring tests pass (tests/test_readme_examples.py)
  • All pre-commit hooks pass
  • Full test suite passes after sequential merge of all 9 PRs (10,656 passed, 194 skipped)

Copilot AI review requested due to automatic review settings April 6, 2026 16:46
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.24%. Comparing base (76d9f68) to head (f5fb74d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1682      +/-   ##
==========================================
+ Coverage   93.22%   93.24%   +0.02%     
==========================================
  Files         157      157              
  Lines        9815     9815              
  Branches     1003     1003              
==========================================
+ Hits         9150     9152       +2     
+ Misses        472      471       -1     
+ Partials      193      192       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the IotBulb class docstring examples to use the current module-based API (bulb.modules[Module.Light], Module.LightPreset) instead of deprecated device-level properties, and adjusts the doctest fixture setup to match the new example outputs.

Changes:

  • Modernize kasa/iot/iotbulb.py docstring examples to use Module.Light / has_feature() / get_feature() and Module.LightPreset.
  • Update doctest expectations (alias text, color temp range example, preset example syntax/output).
  • Set the bulb alias in tests/test_readme_examples.py so the doctest output matches the new docstring.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
kasa/iot/iotbulb.py Updates IotBulb docstring examples to the Module-based interfaces and fixes doctest example issues.
tests/test_readme_examples.py Sets the fixture bulb alias to align doctest output with updated docstring examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Fix :func: -> :meth: Sphinx references for instance methods (iotbulb,
  iotdevice, iotplug, iotstrip, iotdimmer, discover)
- Fix >>> -> ... for continuation lines in code examples across all
  docstrings (device, deviceconfig, discover, feature, module, tutorial,
  light, lightpreset, lighteffect, childsetup, childdevice, iotstrip)
- Fix stale class references: SmartPlug -> IotPlug, SmartBulb -> IotBulb
  (iotstrip, iotdimmer, iotlightstrip)
- Fix set literal -> dict literal bug in lighteffect.py example
- Suppress return values in tutorial.py to fix xdoctest output matching
- Modernize IotBulb docstring to use Module.Light/Module.LightPreset
  interface instead of deprecated device-level properties
- Update test_readme_examples.py fixture for modernized bulb docstring
@ZeliardM ZeliardM force-pushed the docs/modernize-iotbulb-docstring branch from 2615cb7 to f5fb74d Compare April 6, 2026 17:33
@ZeliardM ZeliardM changed the title docs: modernize IotBulb docstring to use Module interface docs: modernize docstrings across the repository Apr 6, 2026
@ZeliardM ZeliardM requested a review from Copilot April 6, 2026 17:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ZeliardM
Copy link
Copy Markdown
Contributor Author

ZeliardM commented Apr 6, 2026

@rytilahti This PR should be good to go as well now for all of the docstring updates.

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.

2 participants