Stubs
provide.foundation.utils.stubs
¶
TODO: Add module docstring.
Classes¶
Functions¶
create_dependency_stub
¶
Create a stub class that raises DependencyError on instantiation or use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
str
|
Name of the missing package (e.g., "httpx", "cryptography") |
required |
feature
|
str
|
Foundation feature name (e.g., "transport", "crypto") |
required |
Returns:
| Type | Description |
|---|---|
type
|
A stub class that raises DependencyError when instantiated or used |
Example
HTTPTransport = create_dependency_stub("httpx", "transport") transport = HTTPTransport() # Raises DependencyError with install instructions
Source code in provide/foundation/utils/stubs.py
create_function_stub
¶
Create a stub function that raises DependencyError when called.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
str
|
Name of the missing package (e.g., "httpx", "mkdocs") |
required |
feature
|
str
|
Foundation feature name (e.g., "transport", "docs") |
required |
Returns:
| Type | Description |
|---|---|
Any
|
A stub function that raises DependencyError when called |
Example
generate_docs = create_function_stub("mkdocs", "docs") generate_docs() # Raises DependencyError with install instructions
Source code in provide/foundation/utils/stubs.py
create_module_stub
¶
Create a stub module-like object that raises DependencyError on attribute access.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
str
|
Name of the missing package (e.g., "httpx") |
required |
feature
|
str
|
Foundation feature name (e.g., "transport") |
required |
Returns:
| Type | Description |
|---|---|
Any
|
A stub object that raises DependencyError on any attribute access |
Example
httpx = create_module_stub("httpx", "transport") httpx.AsyncClient() # Raises DependencyError with install instructions