pleiszenburg/abgleich

Colorized CLI output can upset the typechecker

thorstenspille opened this issue · 2 comments

This issue appears with the current version in master branch:

root@abgleich:~# abgleich snap /etc/abgleich/frequent.yaml
| Typ      |   Geschrieben | Name des Datensatzes   | Snapshot-Name       |
|----------|---------------|------------------------|---------------------|
| Snapshot |      96.0 KiB | ROOT                   | 2021031301_frequent |
| Snapshot |       8.2 GiB | ROOT/pve-1             | 2021031301_frequent |
| Snapshot |      96.0 KiB | data                   | 2021031301_frequent |
Möchten Sie fortfahren? [y/N]: y
Traceback (most recent call last):
  File "/usr/local/bin/abgleich", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/abgleich/cli/snap.py", line 67, in snap
    transactions.run()
  File "/usr/local/lib/python3.9/dist-packages/abgleich/core/transaction.py", line 286, in run
    f'{colorize(" | ".join([str(command) for command in transaction.commands]), "yellow"):s}'
  File "/usr/local/lib/python3.9/dist-packages/typeguard/__init__.py", line 916, in wrapper
    raise TypeError(*exc.args) from None
TypeError: type of the return value must be a tuple; got list instead

Tested with Python3.9 on Manjaro Linux and Debian 11 (bullseye/testing) against a Proxmox 6.3.6 system.
My config:

source:
    zpool: rpool
    prefix:
    host: px
    user: root
target:
    zpool: backup
    prefix: px/prod
    host: px
    user: root
include_root: no
keep_snapshots: 8
always_changed: no
written_threshold: 1048576
check_diff: yes
suffix: _frequent
digits: 3
ignore: []
ssh:
    compression: no
    cipher: aes256-gcm@openssh.com

Python module versions of my pipenv:

$ pipenv run pip list
Package    Version
---------- -------
abgleich   0.0.7
click      7.1.2
pip        21.0.1
PyYAML     5.4.1
setuptools 53.0.0
tabulate   0.8.9
typeguard  2.11.1
wheel      0.36.2

Just tested with develop branch, seems to be fixed there, could not reproduce this issue.

s-m-e commented

@thorstenspille Yes, this is fixed in develop.

Workaround for 0.0.7: Turning off type checks also eliminates this issue.