summaryrefslogtreecommitdiffstats
path: root/contrib/python/annotated-doc/annotated_doc
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2026-03-09 15:01:52 +0300
committerrobot-piglet <[email protected]>2026-03-09 15:19:56 +0300
commitf6fa894e435f87435fb7e9d169d27be34919d02e (patch)
tree9133a7ed545f54d5497f48e35e940a72f108eb2e /contrib/python/annotated-doc/annotated_doc
parent5e4443cb23a723cb03b9a208a3b481e4c03d393e (diff)
Intermediate changes
commit_hash:cc43b6f20066a000a87a4b56d73a1234249e0e8a
Diffstat (limited to 'contrib/python/annotated-doc/annotated_doc')
-rw-r--r--contrib/python/annotated-doc/annotated_doc/__init__.py3
-rw-r--r--contrib/python/annotated-doc/annotated_doc/main.py36
-rw-r--r--contrib/python/annotated-doc/annotated_doc/py.typed0
3 files changed, 39 insertions, 0 deletions
diff --git a/contrib/python/annotated-doc/annotated_doc/__init__.py b/contrib/python/annotated-doc/annotated_doc/__init__.py
new file mode 100644
index 00000000000..a0152a7d12a
--- /dev/null
+++ b/contrib/python/annotated-doc/annotated_doc/__init__.py
@@ -0,0 +1,3 @@
+from .main import Doc as Doc
+
+__version__ = "0.0.4"
diff --git a/contrib/python/annotated-doc/annotated_doc/main.py b/contrib/python/annotated-doc/annotated_doc/main.py
new file mode 100644
index 00000000000..7063c59e450
--- /dev/null
+++ b/contrib/python/annotated-doc/annotated_doc/main.py
@@ -0,0 +1,36 @@
+class Doc:
+ """Define the documentation of a type annotation using `Annotated`, to be
+ used in class attributes, function and method parameters, return values,
+ and variables.
+
+ The value should be a positional-only string literal to allow static tools
+ like editors and documentation generators to use it.
+
+ This complements docstrings.
+
+ The string value passed is available in the attribute `documentation`.
+
+ Example:
+
+ ```Python
+ from typing import Annotated
+ from annotated_doc import Doc
+
+ def hi(name: Annotated[str, Doc("Who to say hi to")]) -> None:
+ print(f"Hi, {name}!")
+ ```
+ """
+
+ def __init__(self, documentation: str, /) -> None:
+ self.documentation = documentation
+
+ def __repr__(self) -> str:
+ return f"Doc({self.documentation!r})"
+
+ def __hash__(self) -> int:
+ return hash(self.documentation)
+
+ def __eq__(self, other: object) -> bool:
+ if not isinstance(other, Doc):
+ return NotImplemented
+ return self.documentation == other.documentation
diff --git a/contrib/python/annotated-doc/annotated_doc/py.typed b/contrib/python/annotated-doc/annotated_doc/py.typed
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/contrib/python/annotated-doc/annotated_doc/py.typed