Skip to content

[BUG]: typing.Self ImportError on Python 3.10 — incompatible with Python < 3.11** #8322

@luckyq

Description

@luckyq

Describe the Bug

Running python3 -m dynamo.frontend --help fails with an ImportError because dynamo/common/configuration/config_base.py imports Self directly from typing, which was only added in Python 3.11. Python 3.10 does not include typing.Self.

Steps to Reproduce

conda create -n myenv python=3.10
conda activate myenv
pip install -e .
python3 -m dynamo.frontend --help

Expected Behavior

Output the help info.

Image

Actual Behavior

Image

Environment

  • OS: Rocky Linux 9.7.0 (x86_64)
  • Python: 3.10.x (CPython, conda env)
  • dynamo version: latest main

Additional Context

Root cause
typing.Self was introduced in Python 3.11 (PEP 673). The import in config_base.py should fall back to typing_extensions for Python < 3.11.

# components/src/dynamo/common/configuration/config_base.py
import sys
if sys.version_info >= (3, 11):
    from typing import Self
else:
    from typing_extensions import Self

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfrontend`python -m dynamo.frontend` and `dynamo-run in=http|text|grpc`pythonPull requests that update python code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions