Skip to content

Python compat issue (for <3.11): ImportError: cannot import name 'Self' from 'typing' #5

@ephe-meral

Description

@ephe-meral

Attempting to import this package with Python <3.11 (3.10 in my local setup) will throw the following error:

ImportError: cannot import name 'Self' from 'typing'

From source:

File "[...]/.venv/lib/python3.10/site-packages/datastar_py/attributes.py", line 7, in <module>
    from typing import Literal, Self, TypeAlias, TypeVar, Union, overload

(Which is apparently due to the Self type declaration being introduced in 3.11)

However, the project does not require Python 3.11, leading to this issue when used in Projects with Python <3.11.
Personally, I have no trouble upgrading to Python 3.11, and that indeed fixes this problem.
But maybe older Versions could easily be supported by not using that type declaration?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions