From bbdf0643a88b239a1d6abfe22f3c915c76885183 Mon Sep 17 00:00:00 2001 From: acul71 Date: Mon, 7 Sep 2026 20:21:14 +0200 Subject: [PATCH] Document Undef in API reference and type stubs. Follow-up polish for #68 so Sphinx and mypy expose the Undef sentinel. Co-authored-by: Cursor --- docs/api_reference.rst | 6 ++++++ newsfragments/68.docs.rst | 1 + stubs/cid.pyi | 11 +++++++++++ 3 files changed, 18 insertions(+) create mode 100644 newsfragments/68.docs.rst diff --git a/docs/api_reference.rst b/docs/api_reference.rst index 2190473..cc423d6 100644 --- a/docs/api_reference.rst +++ b/docs/api_reference.rst @@ -39,6 +39,12 @@ CID classes :inherited-members: :undoc-members: +.. autoclass:: cid.cid._UndefCID + :members: + :undoc-members: + +.. autodata:: Undef + .. autoclass:: CIDJSONEncoder :show-inheritance: :members: diff --git a/newsfragments/68.docs.rst b/newsfragments/68.docs.rst new file mode 100644 index 0000000..b284da0 --- /dev/null +++ b/newsfragments/68.docs.rst @@ -0,0 +1 @@ +Document ``Undef`` in the API reference and type stubs. diff --git a/stubs/cid.pyi b/stubs/cid.pyi index 532001a..87fe390 100644 --- a/stubs/cid.pyi +++ b/stubs/cid.pyi @@ -15,6 +15,7 @@ class BaseCID: @property def buffer(self) -> bytes: ... def encode(self, encoding: str | None = None) -> bytes: ... + def defined(self) -> bool: ... def __eq__(self, other: object) -> bool: ... def __hash__(self) -> int: ... @@ -28,6 +29,16 @@ class CIDv1(BaseCID): def __init__(self, codec: str, multihash: str | bytes) -> None: ... def to_v0(self) -> CIDv0: ... +class _UndefCID: + def defined(self) -> bool: ... + def __bool__(self) -> bool: ... + def __repr__(self) -> str: ... + def __str__(self) -> str: ... + def __eq__(self, other: object) -> bool: ... + def __hash__(self) -> int: ... + +Undef: _UndefCID + # Function overloads for make_cid @overload def make_cid(base58_encoded_multihash: str) -> CIDv0: ...