mistral_common.deprecation
deprecated_import(old_path, new_module, name, version)
Warn once and lazily import a symbol that moved to a new module.
The deprecation warning is emitted only on the first import for a given
(old_path, name) pair, no matter how often the module is re-imported.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old_path
|
str
|
The old module path (e.g. |
required |
new_module
|
str
|
The new module path (e.g. |
required |
name
|
str
|
The symbol name (e.g. |
required |
version
|
str
|
The version in which the symbol will be removed. |
required |
Returns:
| Type | Description |
|---|---|
object
|
The imported symbol from the new module. |
Source code in src/mistral_common/deprecation.py
warn_once(key, message, category, stacklevel)
Emit a warning only on the first call for a given key.
Subsequent calls with the same key are silently ignored, so the user sees each distinct warning exactly once per process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Unique identifier for this warning. Distinct keys produce distinct warnings. |
required |
message
|
str
|
The warning message. |
required |
category
|
type[Warning]
|
The warning category class (e.g., DeprecationWarning). |
required |
stacklevel
|
int
|
Stack level for the warning, so the reported location
points at the caller (see |
required |