Skip to content

Cannot import pyown with python<=3.11.3 #38

@prina404

Description

@prina404

When installing the pyown library in an environment with python<=3.11.3, I get the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.11/site-packages/pyown/__init__.py", line 1, in <module>
    from .client import Client
  File "/usr/local/lib/python3.11/site-packages/pyown/client/__init__.py", line 1, in <module>
    from .base import BaseClient
  File "/usr/local/lib/python3.11/site-packages/pyown/client/base.py", line 7, in <module>
    from .session import SessionType
  File "/usr/local/lib/python3.11/site-packages/pyown/client/session.py", line 3, in <module>
    from ..messages import GenericMessage
  File "/usr/local/lib/python3.11/site-packages/pyown/messages/__init__.py", line 1, in <module>
    from .ack import ACK
  File "/usr/local/lib/python3.11/site-packages/pyown/messages/ack.py", line 4, in <module>
    from .base import BaseMessage, MessageType
  File "/usr/local/lib/python3.11/site-packages/pyown/messages/base.py", line 10, in <module>
    from ..tags import Who, Where
  File "/usr/local/lib/python3.11/site-packages/pyown/tags/__init__.py", line 5, in <module>
    from .who import Who
  File "/usr/local/lib/python3.11/site-packages/pyown/tags/who.py", line 11, in <module>
    class Who(Tag, StrEnum):
  File "/usr/local/lib/python3.11/enum.py", line 478, in __prepare__
    member_type, first_enum = metacls._get_mixins_(cls, bases)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 961, in _get_mixins_
    member_type = mcls._find_data_type_(class_name, bases) or object
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 1000, in _find_data_type_
    raise TypeError('too many data types for %r: %r' % (class_name, data_types))
TypeError: too many data types for 'Who': {<class 'pyown.tags.base.Tag'>, <class 'str'>}

Steps to reproduce

Use a docker image and import the Client module to trigger the exception:

$ docker run --rm python:3.11.3 sh -c "pip install pyown && python -c 'from pyown.client import Client'"

Currently, the latest python version in the Raspberry Pi OS is exactly 3.11.3, preventing the usage of pyown with the default interpreter. A compatibility fix would be greatly appreciated :)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions