Open sumagnadas opened 3 years ago
Thanks for opening an issue @sumagnadas. I'm sorry to hear that you're having a problem with mpris_server
.
This looks like there might be a missing from __future__ import annotations
in the version of mpris_server
you got from PyPI.
Can you provide the output of the following two commands?
python3 -m pip show mpris_server
python3 --version
A quick fix for this might be to add from __future__ import annotations
at the top of your media_player.py
, or use Python 3.9 or above.
I'll check if the issue lies with mpris_server
's package distribution, though.
This is the output of the commands:
(yt-music-mod) sumagnadas@hp-laptop:/mnt/sda2/python/projects/yt-music-mod$ python --version
Python 3.8.10
(yt-music-mod) sumagnadas@hp-laptop:/mnt/sda2/python/projects/yt-music-mod$ python -m pip show mpris_server
Name: mpris-server
Version: 0.4.2
Summary: Publish a MediaPlayer2 MPRIS device to D-Bus.
Home-page: https://alexdelorenzo.dev
Author: Alex DeLorenzo
Author-email: None
License: AGPL-3.0
Location: /mnt/sda2/python/virtualenvs/yt-music-mod/lib/python3.8/site-packages
Requires: typing-extensions, PyGObject, pydbus, emoji, unidecode
Required-by:
Also I tried to fix the problem and it seems like the lines which were causing the problems (list[str]
) were supposed to be like this i think - List[str]
The type validations were going from the wrong type.
So I checked to see if from __future__ import annotations
was present or not and it seems like the import was present in all of the files which caused the problem, yet the error occurred.
I had to change a few lines which fixed the problem for me and the lines were mostly i think either type aliases or type validations like list[str]
(which i changed to List[str]
from typing
) and tuple[str, str, str]
(which I changed to Tuple[str, str, str]
from typing
)
Thanks for providing the output of those commands. There's mpris_server==0.4.3
on PyPI that you can install like so:
python3 -m pip install mpris_server==0.4.3
Check that out, as I'm able to run it on Python 3.7 without a problem, so it should work with Python 3.8.10.
Regarding the use of typing.List[str]
versus the parameterized container list[str]
, as of Python 3.7, use of the annotations
import from __future__
should enable parameterized containers on Python 3.7 and 3.8, and is the default in 3.9, as per PEP 585. Strange that there's this inconsistency, but try the latest version on PyPI and see if you're still running into this error.
So I tried to install the version you told me but it can't find it. I also checked the official PyPI website and it says that the latest version is 0.4.2
.
Also while I make my application work with the workaround as my part of the code wouldn't change even if the error is fixed, can you tell me how to make my app register the event handler?
I cant seem to get it as I am pretty new to event handling and stuff.
So I misinterpreted PEP 585, parameterized containers on Python <3.9 can only be used as variable or function annotations. Using parameterized containers for type aliases isn't supported on versions <3.9.
I apologize for misstating, this issue is 100% because of that misinterpretation. I made some changes to mpris_server
itself, and tested it on 3.7.10. I pushed mpris_server==0.5.1
to PyPI, which should fix this issue.
Thanks again for reporting this!
I will try the fix as soon as possible. Until then, can you direct me to how to make a function or something which will register the event handler from my app's side?
Also, I was seeing the examples like cast_control
and the one stated in the issue. In the issue, can you tell how does on_app_event()
works and what I have to do with it exactly?:sweat_smile:
I had exactly the same issues, I use Python 3.8.10
after the update to version mpris_server==0.5.1
it works without problems. Thanks for the fix and for the library!
I am trying to make a GUI overlay application for my media player which pulls my YT Music playlist and plays songs from there. Now leaving the overlay part and the GUI part, everything was complete so i thought that i should make it work with my media keys and so I found this module and installed it but while trying to import it shows the following error :
What should I do to fix this?