def test_transform_documentation_entry() -> None: provider = DocumentationProvider() assert provider._transform_doc_entry("<[Promise]<?[Error]>>") == "<Optional[Error]>" assert provider._transform_doc_entry("<[Frame]>") == "<Frame>" assert ( provider._transform_doc_entry("<[function]|[string]|[Object]>") == "<[function]|[str]|[Dict]>" ) assert provider._transform_doc_entry("<?[Object]>") == "<Optional[Dict]>"
from typing import Any, get_type_hints # type: ignore from scripts.documentation_provider import DocumentationProvider from scripts.generate_api import ( all_types, api_globals, arguments, header, process_type, return_type, return_value, short_name, signature, ) documentation_provider = DocumentationProvider() def generate(t: Any) -> None: print("") class_name = short_name(t) base_class = t.__bases__[0].__name__ base_sync_class = ("SyncBase" if base_class == "ChannelOwner" or base_class == "object" else base_class) print(f"class {class_name}({base_sync_class}):") print("") print(f" def __init__(self, obj: {class_name}Impl):") print(" super().__init__(obj)") for [name, type] in get_type_hints(t, api_globals).items(): print("") print(" @property")