Error in Type comparison of Flexible Fields declared by plugins
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 31
Description
### Problem
When activating two plugins which [declare the type for a flexible field](https://beets.readthedocs.io/en/stable/dev/plugins.html#flexible-field-types), beets exits with the following exception:
```bash
Traceback (most recent call last):
File "/Users/jackisback/opt/miniconda3/envs/beetsdevel/bin/beet", line 8, in
sys.exit(main())
File "/Users/jackisback/opt/miniconda3/envs/beetsdevel/lib/python3.7/site-packages/beets/ui/__init__.py", line 1266, in main
_raw_main(args)
File "/Users/jackisback/opt/miniconda3/envs/beetsdevel/lib/python3.7/site-packages/beets/ui/__init__.py", line 1249, in _raw_main
subcommands, plugins, lib = _setup(options, lib)
File "/Users/jackisback/opt/miniconda3/envs/beetsdevel/lib/python3.7/site-packages/beets/ui/__init__.py", line 1148, in _setup
library.Item._types.update(plugins.types(library.Item))
File "/Users/jackisback/opt/miniconda3/envs/beetsdevel/lib/python3.7/site-packages/beets/plugins.py", line 344, in types
u'another type.'.format(plugin.name, field)
beets.plugins.PluginConflictException: Plugin acousticbrainz defines flexible field average_loudness which has already been defined with another type.
```
The above error can be reproduced by activating any two plugins (one example is`acousticbrainz`) which declare flexible fields like the code snippet below:
```python
item_types = {
'average_loudness': types.Float(6)
}
```
The expected behaviour is that two plugins which declare the same field with the same type (for example: `types.Float()`) should be able to co-exist.
The actual behaviour is that beets exits with:
> beets.plugins.PluginConflictException: Plugin acousticbrainz defines flexible field average_loudness which has already been defined with another type.
The type comparison here seems to be wrong:
https://github.com/beetbox/beets/blob/b34d1f71a93b3663f70f46a4d5ed08702b14c5ca/beets/plugins.py#L342
because it compares the actual instances instead of their types.
Contributor guide
Research direction
Read the flexible-field type handling in beets/plugins.py around line 342. Reproduce the conflict by activating two plugins that declare the same field type, then verify that matching type declarations coexist while genuinely different types still raise PluginConflictException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100