Skip to content

Cannot import cusser from python using example in readme or from repl #89

Description

@nicciniamh

With the example in the readme I can't import cusser or from the repl.
In the repl
import curses
import cusser

or the readme's exmaple

import curses

from cusser import Cusser

def app(stdscr) -> None:
     """Start a new application."""
     if not isinstance(stdscr, Cusser):
         stdscr = Cusser(stdscr)

     ultra_violet = (100, 83, 148)
     x, y = 34, 12
     stdscr.addstr(
         f"\033[2J\033[{x};{y}H"
         "\033[1;32mHello "
         f"\033[;3;38;2;{';'.join(map(str, ultra_violet))}m"
         "cusser"
         "\033[m 🤬!"
     )
     stdscr.refresh()
     stdscr.getch()

curses.wrapper(app)

I get the following traceback:

Traceback (most recent call last):
  File "/home/nicci/cussertest.py", line 3, in <module>
    from cusser import Cusser
  File "/home/nicci/pyenv/lib/python3.11/site-packages/cusser/__init__.py", line 41, in <module>
    @dataclass
     ^^^^^^^^^
  File "/usr/lib/python3.11/dataclasses.py", line 1220, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/usr/lib/python3.11/dataclasses.py", line 1210, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/dataclasses.py", line 958, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'cusser.color_manager.ColorManager'> for field color_manager is not allowed: use default_factory

I have used both the pip package or by cloning the repo run installing it from there with pip.

If I can assist, please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions