Skip to content

Commit

Permalink
__[gs]etstate__
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jan 17, 2025
1 parent 6f79df9 commit ce6b9a6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sphinx/util/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down

0 comments on commit ce6b9a6

Please sign in to comment.