Skip to content

Commit 78e48bd

Browse files
authored
Merge pull request #20 from comfuture:typing-docmeta
Refactor Doc type handling to use DocMeta protocol
2 parents 3dfc17e + 21b4108 commit 78e48bd

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

function_schema/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
get_type_hints,
1313
)
1414

15-
from .types import FunctionSchema, Doc
15+
from .types import FunctionSchema, Doc, DocMeta
1616
from .utils import unwrap_doc
1717

1818

@@ -102,7 +102,7 @@ def get_function_schema(
102102
# find description in param_args tuple
103103
try:
104104
description = next(
105-
unwrap_doc(arg) for arg in param_args if isinstance(arg, Doc)
105+
unwrap_doc(arg) for arg in param_args if isinstance(arg, DocMeta)
106106
)
107107
except StopIteration:
108108
try:

function_schema/types.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,20 @@
1515
from typing_extensions import Doc
1616
except ImportError:
1717

18-
@runtime_checkable
19-
class Doc(Protocol):
18+
class Doc:
2019
documentation: str
2120

2221
def __init__(self, documentation: str, /):
2322
self.documentation = documentation
2423

2524

25+
@runtime_checkable
26+
class DocMeta(Protocol):
27+
"""Represents the protocol for the Doc class."""
28+
29+
documentation: str
30+
31+
2632
class ParamSchema(TypedDict):
2733
"""
2834
Represents the schema for a parameter.

0 commit comments

Comments
 (0)