bezmi / jvc_projector

Python library to control JVC projectors
MIT License
16 stars 10 forks source link

Import error on jvccommands.py L40 - TypeError: 'type' object is not subscriptable #19

Closed piejanssens closed 1 year ago

piejanssens commented 1 year ago
$ root@homebridge:/var/lib/homebridge $ python3 --version
Python 3.8.10
from jvc_projector_remote import JVCProjector
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/jvc_projector_remote/__init__.py", line 1, in <module>
    from .jvcprojector import *
  File "/usr/local/lib/python3.8/dist-packages/jvc_projector_remote/jvcprojector.py", line 7, in <module>
    from .jvccommands import *
  File "/usr/local/lib/python3.8/dist-packages/jvc_projector_remote/jvccommands.py", line 19, in <module>
    class Command:
  File "/usr/local/lib/python3.8/dist-packages/jvc_projector_remote/jvccommands.py", line 40, in Command
    readwritevals: tuple[dict[str, bytes]] = field(repr=False)
TypeError: 'type' object is not subscriptable
piejanssens commented 1 year ago

It doesn't seem to be compatible with Python 3.8 (which is shipped with Homebridge' Docker image). To fix this, you can use from typing import Dict, Tuple and replace dict with Dict and tuple with Tuple. This should be compatible with 3.8+ too.

bezmi commented 1 year ago

Thanks for the heads up. Are you able to submit a pull request with the changes? I have very limited time until the end of this month.

bezmi commented 1 year ago

Note, best to work directly onto the 0.2.2.post1 tag as it is slightly ahead of master because I forgot to push this commits.

piejanssens commented 1 year ago

@bezmi Could you put these recent changes from that tag into your master branch first, please?

bezmi commented 1 year ago

I've gone ahead and pushed the Dict and Tuple changes as well. Please test and let me know if that fixes python 3.8 compatibility issues and I'll push a new release with the changes.

piejanssens commented 1 year ago

Tested with success on both 3.8 and 3.10.

bezmi commented 1 year ago

fixed with v0.2.3