GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CLI `_echo` doesn't work without `import rich` for non-String reports · Issue #1618 · python-kasa/python-kasa

CLI _echo doesn't work without import rich for non-String reports #1618

New issue
Copy link
New issue
Copy link
Closed as not planned
mash-graz/python-kasa
#1
mash-graz/python-kasa#1
Closed as not planned
CLI _echo doesn't work without import rich for non-String reports#1618
mash-graz/python-kasa
#1
Copy link
Labels
bugSomething isn't workingSomething isn't workingstale

Description

@mash-graz
mash-graz
opened on Nov 29, 2025
Issue body actions

For example this CLI command will throw an exception is rich isn't installed, although it works fine otherwise:

kasa --host 192.168.1.168 --username xxx --password xxx feature check_latest_firmware
Discovering device 192.168.1.168 for 10 seconds
Executing action check_latest_firmware
Raised error: expected string or bytes-like object, got 'UpdateInfo'
Run with --debug enabled to see stacktrace

the reason for this error reported by --debug:

[...]
Raised error: expected string or bytes-like object, got 'UpdateInfo'
Traceback (most recent call last):
[...]
File "/home/mash/.local/share/uv/tools/python-kasa/lib/python3.13/site-packages/kasa/cli/feature.py", line 125, in feature
    echo(response)
    ~~~~^^^^^^^^^^
  File "/home/mash/.local/share/uv/tools/python-kasa/lib/python3.13/site-packages/kasa/cli/common.py", line 57, in echo
    _echo(*args, **kwargs)
    ~~~~~^^^^^^^^^^^^^^^^^
  File "/home/mash/.local/share/uv/tools/python-kasa/lib/python3.13/site-packages/kasa/cli/common.py", line 45, in wrapper
    message = rich_formatting.sub("", message)
TypeError: expected string or bytes-like object, got 'UpdateInfo'

The regex substitution used in this replacement for richs print() function only works for strings.

More complex objects need to be preprocessed by repr() in advance.

Activity

  1. mash-graz
    added a commit that references this issue on Nov 29, 2025

    Fix CLI `_echo` without `import rich` for complex objects

    This issue will close once commit a4cd0b8 is merged into the 'master' branch.
    a4cd0b8
  2. rytilahti commented on Nov 30, 2025

    @rytilahti
    rytilahti
    on Nov 30, 2025
    Member
    More actions

    This seems to work for me, with & without rich (14.2.0) using python 3.12:

    Image

    Which versions are you using?

  3. rytilahti
    added
    bugSomething isn't workingSomething isn't working
    on Nov 30, 2025
  4. mash-graz commented on Nov 30, 2025

    @mash-graz
    mash-graz
    on Nov 30, 2025
    Author
    More actions

    This seems to work for me, with & without rich (14.2.0) using python 3.12.

    Could you please execute this little script (test.py), which should demonstrate the actual cause of this issue:

    import re
    
    class TestObj:
        member_num = 12
        member_str = "xxx"
    
    to = TestObj()
    
    re.sub(r'[x]', '', to)

    The output will look very similar to this:

    Image
  5. github-actions commented on Mar 1, 2026

    @github-actions
    github-actionsBot
    on Mar 1, 2026 – with GitHub Actions
    More actions

    There hasn't been any activity on this issue recently. This issue has been automatically marked as stale because of that. It will be closed if no further activity occurs.
    Please make sure to update to the latest python-kasa version and check if that solves the issue.
    Thank you for your contributions.

  6. github-actions
    added
    stale
    on Mar 1, 2026
  7. github-actions
    closed this as not plannedon Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't workingstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.