Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
main.py37 linesDownload Raw Back to annotated_doc
1class Doc:2    """Define the documentation of a type annotation using `Annotated`, to be3        used in class attributes, function and method parameters, return values,4        and variables.5 6    The value should be a positional-only string literal to allow static tools7    like editors and documentation generators to use it.8 9    This complements docstrings.10 11    The string value passed is available in the attribute `documentation`.12 13    Example:14 15    ```Python16    from typing import Annotated17    from annotated_doc import Doc18 19    def hi(name: Annotated[str, Doc("Who to say hi to")]) -> None:20        print(f"Hi, {name}!")21    ```22    """23 24    def __init__(self, documentation: str, /) -> None:25        self.documentation = documentation26 27    def __repr__(self) -> str:28        return f"Doc({self.documentation!r})"29 30    def __hash__(self) -> int:31        return hash(self.documentation)32 33    def __eq__(self, other: object) -> bool:34        if not isinstance(other, Doc):35            return NotImplemented36        return self.documentation == other.documentation37 
codekingpro/portable-devtools · Team Ai