You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per the project metadata (trove classifiers and python_requires setting in setup.py), the project is supposed to support Python 3.7 and up, including in the current version.
However, it will in fact crash at import time in Python 3.7 through 3.9, due to how type annotations are used in lyrics.util, along the lines of:
File "/path/to/lib/python3.8/site-packages/lyrics/util.py", line 33, in <module>
def get_html(url, header=HEADER) -> str | Tuple[str, Exception]:
TypeError: unsupported operand type(s) for |: 'type' and '_GenericAlias'
A union object holds the value of the | (bitwise or) operation on multiple type objects. These types are intended primarily for type annotations. The union type expression enables cleaner type hinting syntax compared to typing.Union...
... Added in version 3.10.
The simplest fix is to simply remove the type annotations from util.py, as the rest of the codebase doesn't appear to be using type annotations anyway (and there seems to be no good reason, yet, to drop support for older Python versions). Alternately, the long-form syntax using typing.Unionis supported since 3.5 (when the typing standard library was added): Union[str, Tuple[str, Exception]], where the corresponding from typing import List, Tuple is modified to include Union as well.
The text was updated successfully, but these errors were encountered:
See investigation here: https://forums.linuxmint.com/viewtopic.php?p=2557029
Per the project metadata (trove classifiers and
python_requires
setting insetup.py
), the project is supposed to support Python 3.7 and up, including in the current version.However, it will in fact crash at import time in Python 3.7 through 3.9, due to how type annotations are used in
lyrics.util
, along the lines of:In short, the
|
operator cannot be used with types in these older versions, as support for this was not added until 3.10:The simplest fix is to simply remove the type annotations from
util.py
, as the rest of the codebase doesn't appear to be using type annotations anyway (and there seems to be no good reason, yet, to drop support for older Python versions). Alternately, the long-form syntax usingtyping.Union
is supported since 3.5 (when thetyping
standard library was added):Union[str, Tuple[str, Exception]]
, where the correspondingfrom typing import List, Tuple
is modified to includeUnion
as well.The text was updated successfully, but these errors were encountered: