FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Strip multi-word rich tags when rich is not installed by wolfgang-aura · Pull Request #1807 · python-kasa/python-kasa · GitHub

Repository navigation

Strip multi-word rich tags when rich is not installed - #1807

Merged
rytilahti merged 1 commit into
python-kasa:masterfrom
wolfgang-aura:mailman/issue-1524
Oct 24, 2026
Merged

rytilahti merged 1 commit into
python-kasa:masterfrom
wolfgang-aura:mailman/issue-1524

Conversation

Copy link
Copy Markdown
Contributor

Without rich installed, kasa prints tags like [bold red]Only discover is available without --host or --alias[/bold red] verbatim. The fallback in kasa/cli/common.py strips only single-word tags (\[/?[a-z]+]), and error() uses the two-word [bold red].

I changed the pattern to \[/?[a-z]+(?: [a-z]+)*], so space-separated lowercase words are stripped too. It is still lowercase only, so bracketed device data such as [ABC] is left alone, as #703 intended. Nothing changes when rich is installed.

The new test in tests/test_cli.py loads a fresh copy of kasa.cli.common with rich blocked and checks that [bold red]...[/bold red] [ABC] prints as ... [ABC]. It fails without the fix.

Tests: pytest tests/test_cli.py, 7019 passed, 204 skipped. ruff check and ruff format --check are clean on both files.

Fixes #1524

This change was prepared with an AI coding assistant (Claude Code, claude-sonnet-5-5) and reviewed before submission.

The fallback regex matched only single-word tags such as [bold], so
error() printed [bold red]...[/bold red] verbatim. Allow space-separated
lowercase words, keeping uppercase bracketed device data intact.

Fixes #1524

codecov Bot commented Oct 23, 2026 •
edited
Loading

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.43%. Comparing base (e29864b) to head (adc1b96).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1807   +/-   ##
=======================================
  Coverage   93.43%   93.43%           
=======================================
  Files         160      160           
  Lines       10095    10095           
  Branches     1042     1042           
=======================================
  Hits         9432     9432           
  Misses        471      471           
  Partials      192      192           

☔ View full report in Codecov by Harness.
📢 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.

rytilahti added this to the 0.12 milestone Oct 24, 2026
rytilahti added the bug Something isn't working label Oct 24, 2026

rytilahti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, thanks @wolfgang-aura!

rytilahti merged commit 0932f30 into python-kasa:master Oct 24, 2026
22 checks passed
rytilahti mentioned this pull request Oct 25, 2026
rytilahti added a commit that referenced this pull request Oct 25, 2026
## [0.12.0](https://github.com/python-kasa/python-kasa/tree/0.12.0)
(2026-10-25)

This release include several compatibility fixes (updated accepted SSL
ciphers, removal of Homekit from the default update cycle).
The new API `Device.supports_module()` provide a way to find out if the
device supports some specific module, e.g., HomeKit, without including
it in the default update cycle.

[Full
Changelog](0.11.0.1...0.12.0)

**Fixed bugs:**

- Keep hub children when the child component list is missing
[\#1797](#1797)
(@Richardtristan)
- Strip multi-word rich tags when rich is not installed
[\#1807](#1807)
(@wolfgang-aura)
- Add Device.supports_module() and stop querying HomeKit for iot devices
[\#1808](#1808)
(@rytilahti)
- Keep multi requests for smartcam devices after a timeout
[\#1802](#1802)
(@hugaraujo)
- Consolidate SSL ciphers and use them in SslTransport
[\#1798](#1798)
(@rytilahti)
- Raise UnsupportedDeviceError instead of crashing on unknown device
types [\#1781](#1781)
(@GhostCoder6969)

**Added support for devices:**

- Add TD21(EU) device fixture
[\#1786](#1786)
(@Smugaski)
- Add P116M(IN) fixture
[\#1795](#1795)
(@Partha-dev01)

**Project maintenance:**

- Add Python 3.15 to supported versions and update pins
[\#1793](#1793)
(@rytilahti)
- Generate the changelog with git-cliff and draft releases in CI
[\#1809](#1809)
(@rytilahti)
- Build and check packages in CI and publish workflows
[\#1782](#1782)
(@rytilahti)

**Other changes:**

- Use the real discovery reply in the TD21 fixture
[\#1800](#1800)
(@Smugaski)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rich formatting is not working on terminal output

2 participants


Back | FazBrowse Home | New Git URL