| """SQLEnv: Interactive Database Query Environment for the OpenEnv Challenge.""" | |
| # --------------------------------------------------------------------------- | |
| # Pydantic / TypedDict compatibility shim | |
| # --------------------------------------------------------------------------- | |
| # The openenv library defines ``Message`` with ``typing.TypedDict``. | |
| # On Python < 3.12, Pydantic 2.x rejects ``typing.TypedDict`` in model | |
| # fields; it requires ``typing_extensions.TypedDict`` instead. We patch | |
| # ``typing.TypedDict`` early so that all downstream imports see the | |
| # compatible version before any Pydantic model is constructed. | |
| import sys | |
| if sys.version_info < (3, 12): | |
| import typing | |
| import typing_extensions | |
| typing.TypedDict = typing_extensions.TypedDict # type: ignore[attr-defined] | |
| try: | |
| from .models import SQLAction, SQLObservation, SQLState | |
| except ImportError: | |
| # When pytest imports this file standalone (not as part of the sql_env | |
| # package), relative imports fail. Fall back to absolute imports. | |
| try: | |
| from sql_env.models import SQLAction, SQLObservation, SQLState # type: ignore[no-redef] | |
| except ImportError: | |
| pass # Imports not available; this file is being collected, not used. | |
| # Client is not imported at package level to avoid loading torch unnecessarily. | |
| # Import it explicitly when needed: from sql_env.client import SQLEnvClient | |
| __all__ = [ | |
| "SQLAction", | |
| "SQLObservation", | |
| "SQLState", | |
| ] | |