The line Tags: Optional[Union[Iterable[str], str]] = None, implies that Tags may be either a string or a list of strings. Yet, there exists no code that handles the case where Tags is a list of strings rather than a single string, resulting in python-libzim raising an exception:
File "libzim/libzim.pyx", line 583, in libzim.Creator.add_metadata
TypeError: Argument 'content' has incorrect type (expected bytes, got list)
Potential fixes:
add special case to Creator.start, Creator.add_metadata or Creator.config_metadata to handle type conversion by joining the list with ";" (Note: Type annotations of add_metadata() do not allow a list fo strings, this may need to be adjusted)
Adjust the type annotations of Creator.config_metadata() to only allow str values for Tags
As you can see, this is a really minor issue and I'd simply open a pull request with the fix, but I am unsure whether the type annotation is right and the code wrong or vice versa.
Currently, the method signature of
Creator.config_metadata
is as follows:The line
Tags: Optional[Union[Iterable[str], str]] = None,
implies thatTags
may be either a string or a list of strings. Yet, there exists no code that handles the case whereTags
is a list of strings rather than a single string, resulting inpython-libzim
raising an exception:Potential fixes:
Creator.start
,Creator.add_metadata
orCreator.config_metadata
to handle type conversion by joining the list with";"
(Note: Type annotations ofadd_metadata()
do not allow a list fo strings, this may need to be adjusted)Creator.config_metadata()
to only allowstr
values forTags
As you can see, this is a really minor issue and I'd simply open a pull request with the fix, but I am unsure whether the type annotation is right and the code wrong or vice versa.