instructor API reference
183 public APIs from instructor (instructor-ai/instructor) — 74 classes, 39 functions, 70 methods. Signatures extracted by static analysis of the actual source.
Repository: instructor-ai/instructor
| Kind | Count |
|---|---|
| Classes | 74 |
| Functions | 39 |
| Methods | 70 |
API list
class
instructor.batch.BatchJobLegacy BatchJob class for backward compatibility
class
instructor.batch.models.BatchErrorError information for failed batch requests
class
instructor.batch.models.BatchErrorInfoBatch-level error information
class
instructor.batch.models.BatchFilesFile references for batch job
class
instructor.batch.models.BatchRequestCountsUnified request counts across providers
class
instructor.batch.models.BatchStatusNormalized batch status across providers
class
instructor.batch.models.BatchSuccessSuccessful batch result with custom_id
class
instructor.batch.models.BatchTimestampsComprehensive timestamp tracking
class
instructor.batch.processor.BatchProcessorUnified batch processor that works across all providers
method
instructor.batch.processor.BatchProcessor.get_batch_status(batch_id:str) -> dict[str, Any]Get batch job status from the provider
method
instructor.batch.processor.BatchProcessor.retrieve_results(batch_id:str) -> list[BatchResult]Retrieve and parse batch results from the provider
class
instructor.batch.providers.anthropic.AnthropicProviderAnthropic batch processing provider
method
instructor.batch.providers.anthropic.AnthropicProvider.cancel_batch(batch_id:str) -> dict[str, Any]Cancel Anthropic batch job
method
instructor.batch.providers.anthropic.AnthropicProvider.delete_batch(batch_id:str) -> dict[str, Any]Delete Anthropic batch job
method
instructor.batch.providers.anthropic.AnthropicProvider.download_results(batch_id:str, file_path:str) -> NoneDownload Anthropic batch results to a file
method
instructor.batch.providers.anthropic.AnthropicProvider.get_status(batch_id:str) -> dict[str, Any]Get Anthropic batch status
method
instructor.batch.providers.anthropic.AnthropicProvider.list_batches(limit:int=10) -> list[BatchJobInfo]List Anthropic batch jobs
method
instructor.batch.providers.anthropic.AnthropicProvider.retrieve_results(batch_id:str) -> strRetrieve Anthropic batch results
method
instructor.batch.providers.anthropic.AnthropicProvider.submit_batch(file_path_or_buffer:Union[str, io.BytesIO], metadata:Optional[dict[str, Any]]=None, **kwargs) -> strSubmit Anthropic batch job
class
instructor.batch.providers.base.BatchProviderAbstract base class for batch processing providers
method
instructor.batch.providers.base.BatchProvider.cancel_batch(batch_id:str) -> dict[str, Any]Cancel a batch job
method
instructor.batch.providers.base.BatchProvider.delete_batch(batch_id:str) -> dict[str, Any]Delete a batch job
method
instructor.batch.providers.base.BatchProvider.download_results(batch_id:str, file_path:str) -> NoneDownload batch results to a file
method
instructor.batch.providers.base.BatchProvider.get_status(batch_id:str) -> dict[str, Any]Get the status of a batch job
method
instructor.batch.providers.base.BatchProvider.list_batches(limit:int=10) -> list[BatchJobInfo]List batch jobs
method
instructor.batch.providers.base.BatchProvider.retrieve_results(batch_id:str) -> strRetrieve batch results as a string
method
instructor.batch.providers.base.BatchProvider.submit_batch(file_path_or_buffer:Union[str, io.BytesIO], metadata:Optional[dict[str, Any]]=None, **kwargs) -> strSubmit a batch job and return the job ID
func
instructor.batch.providers.get_provider(provider_name:str) -> BatchProviderFactory function to get the appropriate provider instance
class
instructor.batch.providers.openai.OpenAIProviderOpenAI batch processing provider
method
instructor.batch.providers.openai.OpenAIProvider.cancel_batch(batch_id:str) -> dict[str, Any]Cancel OpenAI batch job
method
instructor.batch.providers.openai.OpenAIProvider.delete_batch(batch_id:str) -> dict[str, Any]Delete OpenAI batch job
method
instructor.batch.providers.openai.OpenAIProvider.download_results(batch_id:str, file_path:str) -> NoneDownload OpenAI batch results to a file
method
instructor.batch.providers.openai.OpenAIProvider.get_status(batch_id:str) -> dict[str, Any]Get OpenAI batch status
method
instructor.batch.providers.openai.OpenAIProvider.list_batches(limit:int=10) -> list[BatchJobInfo]List OpenAI batch jobs
method
instructor.batch.providers.openai.OpenAIProvider.retrieve_results(batch_id:str) -> strRetrieve OpenAI batch results
method
instructor.batch.providers.openai.OpenAIProvider.submit_batch(file_path_or_buffer:Union[str, io.BytesIO], metadata:Optional[dict[str, Any]]=None, **kwargs) -> strSubmit OpenAI batch job
method
instructor.batch.request.BatchRequest.get_json_schema() -> dict[str, Any]Generate JSON schema from response_model
func
instructor.batch.utils.extract_results(results:list[BatchResult]) -> list[T]Extract just the result objects from successful results
func
instructor.batch.utils.filter_errors(results:list[BatchResult]) -> list[BatchError]Filter to only error results
func
instructor.batch.utils.filter_successful(results:list[BatchResult]) -> list[BatchSuccess[T]]Filter to only successful results
func
instructor.batch.utils.get_results_by_custom_id(results:list[BatchResult]) -> dict[str, BatchResult]Create a dictionary mapping custom_id to results
class
instructor.cache.BaseCacheAbstract cache contract.
method
instructor.cache.BaseCache.get(key:str) -> Any | NoneReturn *None* to indicate a cache miss.
method
instructor.cache.BaseCache.set(key:str, value:Any, ttl:int | None=None) -> NoneStore *value* under *key*.
class
instructor.cache.DiskCacheWrapper around `diskcache.Cache`.
func
instructor.cache.make_cache_key(*messages:Any, *model:str | None, *response_model:type[BaseModel] | None, *mode:str | None=None) -> strCompute a *deterministic* cache key.
func
instructor.cli.cli.docs(query:Optional[str]=typer.Argument(None, help='Search the documentation')) -> NoneOpen the instructor documentation website.
func
instructor.cli.deprecated_hub.hub() -> NoneThis command has been deprecated.
func
instructor.cli.usage.get_model_cost(model:ModelNames) -> Union[dict[str, float], float]Get the cost details for a given model.
func
instructor.distil.format_function(func:Callable[..., Any]) -> strFormat a function as a string with docstring and body.
func
instructor.distil.get_signature_from_fn(fn:Callable[..., Any]) -> strGet the function signature as a string.
class
instructor.v2.core.client.InstructorSync client wrapper that adds structured output support.
method
instructor.v2.core.client.Instructor.handle_kwargs(kwargs:dict[str, Any]) -> dict[str, Any]Handle and process keyword arguments for the API call.
class
instructor.v2.core.client.ResponseHelper for responses API using a patched client.
func
instructor.v2.core.decorators.decorator(handler_class:type) -> typeRegister the handler class.
class
instructor.v2.core.errors.AsyncValidationErrorException raised during async validation.
class
instructor.v2.core.errors.ConfigurationErrorException raised for configuration-related errors.
class
instructor.v2.core.errors.FailedAttemptRepresents a single failed retry attempt.
class
instructor.v2.core.errors.InstructorErrorBase exception for all Instructor-specific errors.
class
instructor.v2.core.errors.MultimodalErrorException raised for multimodal content processing errors.
class
instructor.v2.core.errors.ProviderErrorException raised for provider-specific errors.
class
instructor.v2.core.errors.ResponseParsingErrorException raised when unable to parse the LLM response.
class
instructor.v2.core.errors.ValidationErrorException raised when LLM response validation fails.
class
instructor.v2.core.exceptions.RegistryValidationMixinMixin providing registry validation helper methods.
func
instructor.v2.core.function_calls.response_schema(cls:type[Model]) -> type[Model]Wrap a Pydantic model class to add ResponseSchema behavior.
class
instructor.v2.core.handler.ModeHandlerBase class for mode handlers.
class
instructor.v2.core.hooks.CompletionKwargsHandlerProtocol for completion kwargs handlers.
class
instructor.v2.core.hooks.CompletionResponseHandlerProtocol for completion response handlers.
class
instructor.v2.core.hooks.HooksHooks class for handling and emitting events related to completion processes.
method
instructor.v2.core.hooks.Hooks.clear(hook_name:HookNameType | None=None) -> NoneClear handlers for a specific event or all events.
method
instructor.v2.core.hooks.Hooks.combine(*hooks_instances:Hooks) -> HooksCombine multiple Hooks instances into a new one.
method
instructor.v2.core.hooks.Hooks.copy() -> HooksCreate a deep copy of this Hooks instance.
method
instructor.v2.core.hooks.Hooks.emit(hook_name:HookName, *args:Any, **kwargs:Any) -> NoneGeneric method to emit events for any hook type.
method
instructor.v2.core.hooks.Hooks.emit_completion_arguments(*args:Any, **kwargs:Any) -> NoneEmit a completion arguments event.
method
instructor.v2.core.hooks.Hooks.emit_completion_error(error:Exception, **kwargs:Any) -> NoneEmit a completion error event.
method
instructor.v2.core.hooks.Hooks.emit_completion_last_attempt(error:Exception, **kwargs:Any) -> NoneEmit a completion last attempt event.
method
instructor.v2.core.hooks.Hooks.emit_completion_response(response:Any) -> NoneEmit a completion response event.
method
instructor.v2.core.hooks.Hooks.emit_parse_error(error:Exception, **kwargs:Any) -> NoneEmit a parse error event.
method
instructor.v2.core.hooks.Hooks.get_hook_name(hook_name:HookNameType) -> HookNameConvert a string hook name to its corresponding enum value.
method
instructor.v2.core.hooks.Hooks.off(hook_name:HookNameType, handler:HandlerType) -> NoneRemove a specific handler from an event.
method
instructor.v2.core.hooks.Hooks.on(hook_name:HookNameType, handler:HandlerType) -> NoneRegister an event handler for a specific event.
class
instructor.v2.core.hooks.ParseErrorHandlerProtocol for parse error handlers.
class
instructor.v2.core.mode.ModeMode enumeration for patching LLM API clients.
method
instructor.v2.core.mode.Mode.json_modes() -> set['Mode']Returns a set of all JSON-based modes.
method
instructor.v2.core.mode.Mode.tool_modes() -> set['Mode']Returns a set of all tool-based modes.
method
instructor.v2.core.mode.Mode.warn_deprecated_mode(mode:'Mode') -> NoneWarn about provider-specific mode deprecation.
func
instructor.v2.core.mode.reset_deprecated_mode_warnings() -> NoneReset deprecation warning tracking.
method
instructor.v2.core.multimodal.Audio.autodetect(source:str | Path) -> AudioAttempt to autodetect an audio from a source string or Path.
method
instructor.v2.core.multimodal.Audio.from_gs_url(data_uri:str, timeout:int=30) -> AudioCreate an Audio instance from a Google Cloud Storage URL.
method
instructor.v2.core.multimodal.Audio.from_path(path:Union[str, Path]) -> AudioCreate an Audio instance from a file path.
method
instructor.v2.core.multimodal.Audio.from_url(url:str) -> AudioCreate an Audio instance from a URL.
method
instructor.v2.core.multimodal.Image.from_gs_url(data_uri:str, timeout:int=30) -> ImageCreate an Image instance from a Google Cloud Storage URL.
class
instructor.v2.core.multimodal.ImageWithCacheControlImage with Anthropic prompt caching support.
method
instructor.v2.core.multimodal.PDF.autodetect(source:str | Path) -> PDFAttempt to autodetect a PDF from a source string or Path.
method
instructor.v2.core.multimodal.PDF.from_gs_url(data_uri:str, timeout:int=30) -> PDFCreate a PDF instance from a Google Cloud Storage URL.
method
instructor.v2.core.multimodal.PDF.to_bedrock(name:str | None=None) -> dict[str, Any]Convert to Bedrock's document format.
class
instructor.v2.core.multimodal.PDFWithCacheControlPDF with Anthropic prompt caching support.
func
instructor.v2.core.patch.apatch(client:AsyncOpenAI, mode:Mode=Mode.TOOLS, provider:Provider=Provider.OPENAI) -> AsyncOpenAIDeprecated alias for :func:`patch`.
class
instructor.v2.core.protocols.RequestHandlerPrepares request kwargs for a specific mode.
class
instructor.v2.core.protocols.ResponseParserParses API response into validated Pydantic model.
class
instructor.v2.core.protocols.StreamExtractorExtract JSON chunks from a streaming response.
class
instructor.v2.core.providers.ProviderSupported provider identifiers.
func
instructor.v2.core.providers.get_provider(base_url:str) -> ProviderDetect the provider based on the base URL.
func
instructor.v2.core.providers.provider_from_mode(mode:Mode, default:Provider=Provider.OPENAI) -> ProviderInfer provider from a provider-specific Mode.
class
instructor.v2.core.registry.ModeHandlersCollection of handlers for a specific mode.
class
instructor.v2.core.registry.ModeRegistryCentral registry for mode handlers.
method
instructor.v2.core.registry.ModeRegistry.get_handler_class(provider:Provider, mode:Mode) -> type | NoneGet the handler class for a mode.
method
instructor.v2.core.registry.ModeRegistry.get_handlers(provider:Provider, mode:Mode) -> ModeHandlersGet all handlers for a mode.
method
instructor.v2.core.registry.ModeRegistry.get_modes_for_provider(provider:Provider) -> list[Mode]Get all registered modes for a provider.
method
instructor.v2.core.registry.ModeRegistry.get_providers_for_mode(mode:Mode) -> list[Provider]Get all providers that support a mode.
method
instructor.v2.core.registry.ModeRegistry.is_registered(provider:Provider, mode:Mode) -> boolCheck if a mode is registered.
method
instructor.v2.core.registry.ModeRegistry.list_modes() -> list[tuple[Provider, Mode]]List all registered modes.
method
instructor.v2.core.registry.ModeRegistry.register_lazy(provider:Provider, mode:Mode, loader:Callable[[], ModeHandlers]) -> NoneRegister a lazy loader for a mode.
func
instructor.v2.core.templating.apply_template(text:str, context:dict[str, Any]) -> strApply Jinja2 template to the given text.
class
instructor.v2.core.utils.classpropertyDescriptor for class-level properties.
func
instructor.v2.core.utils.disable_pydantic_error_url() -> NoneDisable URLs in Pydantic ValidationError messages.
func
instructor.v2.core.utils.is_async(func:Callable[..., Any]) -> boolReturn whether a callable is async, following wrapped callables.
method
instructor.v2.dsl.json_tracker.JsonCompleteness.get_complete_paths() -> set[str]Return all paths that are complete.
method
instructor.v2.dsl.json_tracker.JsonCompleteness.is_path_complete(path:str) -> boolCheck if the sub-structure at the given path is complete.
method
instructor.v2.dsl.json_tracker.JsonCompleteness.is_root_complete() -> boolCheck if the root JSON structure is complete.
func
instructor.v2.dsl.json_tracker.is_json_complete(json_str:str) -> boolCheck if a JSON string represents a complete structure.
func
instructor.v2.dsl.maybe.Maybe(model:type[T]) -> type[MaybeBase[T]]Create a Maybe model for a given Pydantic model.
class
instructor.v2.dsl.partial.PartialLiteralMixinDEPRECATED: This mixin is no longer necessary.
class
instructor.v2.providers.anthropic.handlers.AnthropicHandlerBaseCommon utilities for Anthropic handlers.
class
instructor.v2.providers.anthropic.handlers.AnthropicJSONHandlerHandler for Anthropic JSON mode.
class
instructor.v2.providers.anthropic.handlers.AnthropicParallelToolsHandlerHandler for Anthropic parallel tool calling.
class
instructor.v2.providers.anthropic.handlers.AnthropicToolsHandlerHandler for Anthropic TOOLS mode.
func
instructor.v2.providers.anthropic.handlers.extract_system_messages(messages:list[dict[str, Any]]) -> list[SystemMessage]Extract system messages from a list of messages.
func
instructor.v2.providers.anthropic.usage.initialize_usage() -> AnyCreate an empty Anthropic usage accumulator.
class
instructor.v2.providers.bedrock.handlers.BedrockMDJSONHandlerHandler for Bedrock MD_JSON mode.
class
instructor.v2.providers.bedrock.handlers.BedrockToolsHandlerHandler for Bedrock TOOLS mode.
func
instructor.v2.providers.bedrock.handlers.generate_bedrock_schema(response_model:type[Any]) -> dict[str, Any]Generate Bedrock tool schema from a Pydantic model.
func
instructor.v2.providers.bedrock.handlers.handle_bedrock_json(response_model:type[Any], new_kwargs:dict[str, Any]) -> tuple[type[Any], dict[str, Any]]Handle Bedrock JSON mode.
func
instructor.v2.providers.bedrock.handlers.handle_bedrock_tools(response_model:type[Any] | None, new_kwargs:dict[str, Any]) -> tuple[type[Any] | None, dict[str, Any]]Handle Bedrock tools mode.
class
instructor.v2.providers.cohere.handlers.CohereJSONSchemaHandlerHandler for Cohere JSON_SCHEMA mode.
class
instructor.v2.providers.cohere.handlers.CohereMDJSONHandlerHandler for Cohere MD_JSON mode.
class
instructor.v2.providers.cohere.handlers.CohereToolsHandlerHandler for Cohere TOOLS mode.
class
instructor.v2.providers.gemini.handlers.GeminiHandlerBaseBase handler for Gemini modes.
class
instructor.v2.providers.gemini.handlers.GeminiJSONHandlerHandler for Gemini JSON mode.
class
instructor.v2.providers.gemini.handlers.GeminiToolsHandlerHandler for Gemini TOOLS mode.
func
instructor.v2.providers.gemini.handlers.parse_gemini_json(response_model:type[BaseModel], completion:Any, validation_context:dict[str, Any] | None=None, strict:bool | None=None) -> BaseModelParse Gemini text JSON responses.
func
instructor.v2.providers.gemini.handlers.parse_gemini_tools(response_model:type[BaseModel], completion:Any, validation_context:dict[str, Any] | None=None, strict:bool | None=None) -> BaseModelParse Gemini tool-call responses.
func
instructor.v2.providers.gemini.utils.reask_genai_tools(*args:Any, **kwargs:Any) -> dict[str, Any]Compatibility shim for the GenAI-owned reask helper.
class
instructor.v2.providers.genai.handlers.GenAIHandlerBaseCommon utilities shared across GenAI mode handlers.
class
instructor.v2.providers.genai.handlers.GenAIToolsHandlerMode handler for GenAI tools/function calling.
func
instructor.v2.providers.genai.templating.process_message(message:Any, context:dict[str, Any], apply_template:Callable[[str, dict[str, Any]], str]) -> AnyApply templates to GenAI Content parts.
func
instructor.v2.providers.mistral.client.async_wrapper(*args:Any, **wrapper_kwargs:Any) -> AnyAsync wrapper that handles streaming.
func
instructor.v2.providers.mistral.client.sync_wrapper(*args:Any, **wrapper_kwargs:Any) -> AnySync wrapper that handles streaming.
class
instructor.v2.providers.mistral.handlers.MistralToolsHandlerHandler for Mistral TOOLS mode.
method
instructor.v2.providers.mistral.handlers.MistralToolsHandler.handle_reask(kwargs:dict[str, Any], response:Any, exception:Exception) -> dict[str, Any]Handle reask for tools mode.
class
instructor.v2.providers.openai.handlers.OpenAIParallelToolsHandlerHandler for OpenAI parallel tool calling.
class
instructor.v2.providers.openai.handlers.OpenAIResponsesToolsHandlerHandler for OpenAI Responses API with tools.
method
instructor.v2.providers.openai.handlers.OpenAIResponsesToolsHandler.handle_reask(kwargs:dict[str, Any], response:Any, exception:Exception) -> dict[str, Any]Handle reask for Responses API.
class
instructor.v2.providers.openai.handlers.OpenAIToolsHandlerHandler for OpenAI TOOLS mode.
method
instructor.v2.providers.openai.handlers.OpenAIToolsHandler.handle_reask(kwargs:dict[str, Any], response:ChatCompletion, exception:Exception) -> dict[str, Any]Handle reask for tools mode.
method
instructor.v2.providers.openai.handlers.OpenAIToolsHandler.prepare_request(response_model:Any, kwargs:dict[str, Any]) -> tuple[Any, dict[str, Any]]Prepare request with tool definitions.
class
instructor.v2.providers.openrouter.handlers.OpenRouterJSONSchemaHandlerHandler for OpenRouter structured outputs.
class
instructor.v2.providers.perplexity.handlers.PerplexityMDJSONHandlerHandler for Perplexity JSON mode.
func
instructor.v2.providers.perplexity.handlers.handle_perplexity_json(response_model:type[Any], new_kwargs:dict[str, Any]) -> tuple[type[Any], dict[str, Any]]Handle Perplexity JSON mode.
class
instructor.v2.providers.vertexai.handlers.VertexAIHandlerBaseBase handler for VertexAI modes.
class
instructor.v2.providers.vertexai.handlers.VertexAIJSONHandlerHandler for VertexAI JSON mode.
class
instructor.v2.providers.vertexai.handlers.VertexAIParallelToolsHandlerHandler for VertexAI parallel tools mode.
class
instructor.v2.providers.vertexai.handlers.VertexAIToolsHandlerHandler for VertexAI TOOLS mode.
class
instructor.v2.providers.writer.handlers.WriterJSONSchemaHandlerHandler for Writer native JSON schema mode.
class
instructor.v2.providers.writer.handlers.WriterMDJSONHandlerHandler for Writer MD_JSON mode.
method
instructor.v2.providers.writer.handlers.WriterMDJSONHandler.handle_reask(kwargs:dict[str, Any], response:Any, exception:Exception) -> dict[str, Any]Handle reask for Writer MD_JSON mode.
class
instructor.v2.providers.writer.handlers.WriterToolsHandlerHandler for Writer TOOLS mode.
method
instructor.v2.providers.writer.handlers.WriterToolsHandler.handle_reask(kwargs:dict[str, Any], response:Any, exception:Exception) -> dict[str, Any]Handle reask for Writer tools mode.
func
instructor.v2.providers.writer.handlers.handle_writer_json(response_model:type[Any], new_kwargs:dict[str, Any]) -> tuple[type[Any], dict[str, Any]]Handle Writer JSON mode.
func
instructor.v2.providers.writer.handlers.handle_writer_tools(response_model:type[Any], new_kwargs:dict[str, Any]) -> tuple[type[Any], dict[str, Any]]Handle Writer tools mode.
class
instructor.v2.providers.xai.handlers.XAIHandlerBaseBase class for xAI handlers with shared utilities.
class
instructor.v2.providers.xai.handlers.XAIJSONSchemaHandlerHandler for xAI JSON_SCHEMA mode.
method
instructor.v2.providers.xai.handlers.XAIJSONSchemaHandler.handle_reask(kwargs:dict[str, Any], response:Any, exception:Exception) -> dict[str, Any]Handle reask for JSON schema mode.
class
instructor.v2.providers.xai.handlers.XAIMDJSONHandlerHandler for xAI MD_JSON mode.
method
instructor.v2.providers.xai.handlers.XAIMDJSONHandler.handle_reask(kwargs:dict[str, Any], response:Any, exception:Exception) -> dict[str, Any]Handle reask for MD_JSON mode.
class
instructor.v2.providers.xai.handlers.XAIParallelToolsHandlerHandler for xAI parallel tool calling.
method
instructor.v2.providers.xai.handlers.XAIParallelToolsHandler.handle_reask(kwargs:dict[str, Any], response:Any, exception:Exception) -> dict[str, Any]Handle reask for parallel tools mode.
class
instructor.v2.providers.xai.handlers.XAIToolsHandlerHandler for xAI TOOLS mode.
method
instructor.v2.providers.xai.handlers.XAIToolsHandler.handle_reask(kwargs:dict[str, Any], response:Any, exception:Exception) -> dict[str, Any]Handle reask for tools mode.
func
instructor.v2.providers.xai.handlers.handle_xai_json(response_model:type[Any] | None, new_kwargs:dict[str, Any]) -> tuple[type[Any] | None, dict[str, Any]]Handle xAI JSON mode.
func
instructor.v2.providers.xai.handlers.handle_xai_tools(response_model:type[Any] | None, new_kwargs:dict[str, Any]) -> tuple[type[Any] | None, dict[str, Any]]Handle xAI tools mode.
class
instructor.v2.validation.async_validators.AsyncValidationContextCarry context through async validation hooks.
func
instructor.v2.validation.async_validators.async_field_validator(field:str, *fields:str) -> Callable[[T], T]Mark a callable as an async field validator.
About this data
These signatures were extracted from the public source of instructor-ai/instructor
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.