geigerzaehler / beets-alternatives

Beets plugin to manage external files
MIT License
93 stars 21 forks source link

Beet alt raises AttributeError with Python 3.7 #35

Closed daviddavo closed 5 years ago

daviddavo commented 5 years ago
➜  beets-alternatives git:(master) beet alt                  
Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.9', 'console_scripts', 'beet')()
  File "/usr/lib/python3.7/site-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/usr/lib/python3.7/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/davo/Documentos/beets-alternatives/beetsplug/alternatives.py", line 79, in func
    opts.func(lib, opts)
AttributeError: 'Namespace' object has no attribute 'func'
wisp3rwind commented 5 years ago

Would you mind providing some more details about how to reproduce this? In particular, exact versions/git commits for beets/beets-alternatives. We're testing quite a few versions of beets and python on Travis, and right now they all seem to build correctly.

EDIT: beets-alternatives is in principle working correctly, isn't it? This should only happen when you run exactly beet alt, omitting the beet alt update subcommand. All of the plugin functionality is actually behind this subcommand, beet alt isn't supposed to do anything. Nevertheless, it should give an intelligible error message...

daviddavo commented 5 years ago
➜  beets-alternatives git:(master) beet --version
beets version 1.4.9
Python version 3.7.4
➜  beets-alternatives git:(master) beet alt         
Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.9', 'console_scripts', 'beet')()
  File "/usr/lib/python3.7/site-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/usr/lib/python3.7/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.7/site-packages/beets_alternatives-0.9.0-py3.7.egg/beetsplug/alternatives.py", line 79, in func
    opts.func(lib, opts)
AttributeError: 'Namespace' object has no attribute 'func'
geigerzaehler commented 5 years ago

As @wisp3rwind pointed out this is indeed an issue with the implementation of AlternativeCommand and persists across all versions of python and beets.

I would suggest showing an error to the user that a command is required. This should be easy to accomplish with argparse. Do you want to give it a try @daviddavo?

wisp3rwind commented 5 years ago

I can also do this (will not before the weekend, if you feel like tackling the issue yourself, just go ahead @daviddavo)