From ce6b9a6f48dbbd28676913b1902225dc9f86f891 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 17 Jan 2025 00:28:34 +0000 Subject: [PATCH] __[gs]etstate__ --- sphinx/util/inventory.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sphinx/util/inventory.py b/sphinx/util/inventory.py index ebb47bd0283..aee8aa3cdb8 100644 --- a/sphinx/util/inventory.py +++ b/sphinx/util/inventory.py @@ -263,6 +263,16 @@ def __delattr__(self, key: str) -> NoReturn: msg = '_InventoryItem is immutable' raise AttributeError(msg) + def __getstate__(self) -> tuple[str, str, str, str]: + return self.project_name, self.project_version, self.uri, self.display_name + + def __setstate__(self, state: tuple[str, str, str, str]) -> None: + project_name, project_version, uri, display_name = state + object.__setattr__(self, 'project_name', project_name) + object.__setattr__(self, 'project_version', project_version) + object.__setattr__(self, 'uri', uri) + object.__setattr__(self, 'display_name', display_name) + def __getitem__(self, key: int | slice) -> str | tuple[str, ...]: warnings.warn( 'The tuple interface for _InventoryItem objects is deprecated.',