Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aphrodite/config/structured_outputs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import hashlib
from typing import Any, Literal, Self
from typing import Any, Literal

from pydantic import model_validator
from pydantic.dataclasses import dataclass
from typing_extensions import Self
Comment on lines 1 to +6

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

For better compatibility and future-proofing, it's recommended to use a conditional import for Self based on the Python version. This ensures that the native typing.Self is used on Python 3.11+ while falling back to typing_extensions on older versions. This avoids an unnecessary dependency on typing_extensions for this feature on newer Python versions and makes the code's intent clearer.

Suggested change
import hashlib
from typing import Any, Literal, Self
from typing import Any, Literal
from pydantic import model_validator
from pydantic.dataclasses import dataclass
from typing_extensions import Self
import hashlib
import sys
from typing import Any, Literal
from pydantic import model_validator
from pydantic.dataclasses import dataclass
if sys.version_info < (3, 11):
from typing_extensions import Self
else:
from typing import Self


from aphrodite.config.utils import config

Expand Down