vit-project / vit

VIT is a lightweight, fast, curses-based front end to Taskwarrior
MIT License
492 stars 51 forks source link

KeyError: ’type’ right after installation with homebrew #343

Closed kingkaos closed 1 year ago

kingkaos commented 1 year ago

I jsut installed vit using homebrew on macos Ventura (13.4.1) with brew install vit and after trying to run vit I received the following Python error:

Traceback (most recent call last):
  File "/opt/homebrew/bin/vit", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/Cellar/vit/2.3.1/libexec/lib/python3.11/site-packages/vit/command_line.py", line 5, in main
    Application(options, filters)
  File "/opt/homebrew/Cellar/vit/2.3.1/libexec/lib/python3.11/site-packages/vit/application.py", line 81, in __init__
    self.refresh(False)
  File "/opt/homebrew/Cellar/vit/2.3.1/libexec/lib/python3.11/site-packages/vit/application.py", line 963, in refresh
    self.bootstrap(load_early_config)
  File "/opt/homebrew/Cellar/vit/2.3.1/libexec/lib/python3.11/site-packages/vit/application.py", line 158, in bootstrap
    self.markers = Markers(self.config, self.task_config)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/vit/2.3.1/libexec/lib/python3.11/site-packages/vit/markers.py", line 42, in __init__
    self.udas = uda.get_configured(self.task_config)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/vit/2.3.1/libexec/lib/python3.11/site-packages/vit/uda.py", line 10, in get_configured
    return {k:v['type'] for k, v in subtree['uda'].items()}
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/vit/2.3.1/libexec/lib/python3.11/site-packages/vit/uda.py", line 10, in <dictcomp>
    return {k:v['type'] for k, v in subtree['uda'].items()}
              ~^^^^^^^^
KeyError: ‚type'

I tried to install vit using the development instructions (using virtual environment and Python 3.8.17) but got the same KeyError. Everything is the same (despite the paths, since this time I used a cloned repository and not brew).

Steps to reproduce:

  1. brew install vit
  2. vit

I expected that vit would work out of the box with brew.

I tested it with the default TaskWarrior settings.

I appreciate any help.

thehunmonkgroup commented 1 year ago

This is most likely an issue with a .taskrc config attribute.

Please remove your custom .taskrc configuration and start with a bare minimum .taskrc -- if Vit loads under this condition, then start adding back items to your config until you find the problem config attribute.

kingkaos commented 1 year ago

Hallo, thank you for the advice.

You have been right, I modified my .taskrc before and thought that I removed all custom settings to end up with the default settings… I’ve overseen one line.

Thanks :)

thehunmonkgroup commented 1 year ago

Is the problem setting a valid Taskwarrior setting or was it a syntax error?

kingkaos commented 1 year ago

I tried 'taskwarrior-tui' before 'vit'. It was a valid 'taskwarrior-tui' setting but not a setting for 'Taskwarrior' itself. Since 'taskwarrior-tui' uses also the '.taskrc' for configuration this lead to this error message.

ferdinandyb commented 1 year ago

@kingkaos have you figured out how to marry the two?

ferdinandyb commented 1 year ago

On the other hand: if taskwarrior itself does not complain, I don't think vit should

ferdinandyb commented 1 year ago

@thehunmonkgroup How would you feel about changing that line to

        return {k: v["type"] for k, v in subtree["uda"].items() if "type" in v}

? It seems to work fine locally.

thehunmonkgroup commented 1 year ago

This seems more like a structural issue with taskwarrior-tui.

VIT doesn't add any settings to .taskrc, instead it uses its own configuration file, which prevents polluting .taskrc with non-Taskwarrior settings.

I believe the correct solution is to file an issue with taskwarrior-tui for restructuring their approach to configuring the software.

ferdinandyb commented 1 year ago

I agree with you on that, so I'll file an issue. But I think it still might be worthwhile to consider, since taskwarrior itself doesn't trip up on this and the 3rd party application guide also does not mention anything about this, so other applications might still choose to do this.

thehunmonkgroup commented 1 year ago

I don't recall any software documentation saying "please don't put stuff in our configuration file".

IMO it's commonly understood practice for an app to use its own configuration system for application specific settings.

Taskwarrior and VIT use different parsing mechanisms, it may be entirely incidental that it's not barfing on this non-Taskwarrior setting -- I don't think that's a compelling reason for VIT to parse .taskrc differently.

If VIT barfs on a valid Taskwarrior setting, that is something VIT should accommodate.

ferdinandyb commented 1 year ago

On Sun Sep 03, 2023 at 20:29, thehunmonkgroup wrote:

I don't recall any software documentation saying "please don't put stuff in our configuration file".

IMO it's commonly understood practice for an app to use its own configuration system for application specific settings.

Taskwarrior and VIT use different parsing mechanisms, it may be entirely incidental that it's not barfing on this non-Taskwarrior setting -- I don't think that's a compelling reason for VIT to parse .taskrc differently.

If VIT barfs on a valid Taskwarrior setting, that is something VIT should accommodate.

You're right, point acknowledged :)