Skip to content

Commit f178806

Browse files
authored
fix(exceptions): restore backwards compatibility for instructor.exceptions imports (#1789)
## Summary - Restore backwards compatibility for `instructor.exceptions` imports that broke in v1.11.0 - Add deprecation warnings to guide users to new import path `instructor.core` - Bump version to 1.11.2 (patch version for backwards compatibility fix) ## Problem Version 1.11.0 introduced a breaking change by removing the backwards compatibility module `instructor/exceptions.py`. This caused imports like `from instructor.exceptions import InstructorRetryException` to fail, breaking downstream applications without warning. ## Solution - Recreated `instructor/exceptions.py` with proper re-exports from `instructor.core.exceptions` - Added deprecation warnings to guide users to the recommended import path - Used proper semantic versioning (patch bump) for a backwards compatibility fix ## Test plan - [x] Test that old import path works: `from instructor.exceptions import InstructorRetryException` - [x] Test that new import path still works: `from instructor.core import InstructorRetryException` - [x] Verify deprecation warning is shown when using old import path - [x] Run linting and type checking - [x] Version bump to 1.11.2 🤖 Generated with [Claude Code](https://claude.ai/code) <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Restores backwards compatibility for `instructor.exceptions` imports with deprecation warnings and bumps version to 1.11.2. > > - **Behavior**: > - Reintroduces `instructor/exceptions.py` to restore backwards compatibility for imports like `from instructor.exceptions import InstructorRetryException`. > - Adds deprecation warning in `instructor/exceptions.py` to guide users to `instructor.core`. > - **Versioning**: > - Bumps version to 1.11.2 in `pyproject.toml` and `uv.lock` for backwards compatibility fix. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=567-labs%2Finstructor&utm_source=github&utm_medium=referral)<sup> for ff9d88f. You can [customize](https://app.ellipsis.dev/567-labs/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
2 parents 8728751 + ff9d88f commit f178806

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

instructor/exceptions.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""Backward compatibility module for instructor.exceptions imports.
2+
3+
.. deprecated:: 1.11.0
4+
This module is deprecated. Import exceptions from `instructor.core` instead.
5+
For example: `from instructor.core import InstructorRetryException`
6+
"""
7+
8+
import warnings
9+
10+
# Show deprecation warning when this module is imported
11+
warnings.warn(
12+
"Importing from 'instructor.exceptions' is deprecated and will be removed in a future version. "
13+
"Please import from 'instructor.core' instead. "
14+
"For example: 'from instructor.core import InstructorRetryException'",
15+
DeprecationWarning,
16+
stacklevel=2,
17+
)
18+
19+
# Explicit re-exports for better IDE support and clarity
20+
from .core.exceptions import (
21+
AsyncValidationError,
22+
ClientError,
23+
ConfigurationError,
24+
IncompleteOutputException,
25+
InstructorError,
26+
InstructorRetryException,
27+
ModeError,
28+
ProviderError,
29+
ValidationError,
30+
)
31+
32+
__all__ = [
33+
"AsyncValidationError",
34+
"ClientError",
35+
"ConfigurationError",
36+
"IncompleteOutputException",
37+
"InstructorError",
38+
"InstructorRetryException",
39+
"ModeError",
40+
"ProviderError",
41+
"ValidationError",
42+
]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies = [
1717
"diskcache>=5.6.3",
1818
]
1919
name = "instructor"
20-
version = "1.11.1"
20+
version = "1.11.2"
2121
description = "structured outputs for llm"
2222
readme = "README.md"
2323

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)