gitcode_api.utils

Utility helper functions.

Functions

as_dict(-> ~typing.Dict[str, ~typing.Any])

Convert one APIObject to a plain dict, or several to a list of dicts.

as_dict(data: APIObject, deep_copy: bool = False) Dict[str, Any]
as_dict(data: List[APIObject], deep_copy: bool = False) List[Dict[str, Any]]

Convert one APIObject to a plain dict, or several to a list of dicts.

Similar to dataclasses.asdict(). Input is converted with to_dict(). When deep_copy is true, each mapping is copied with copy.deepcopy().

Parameters:
  • data – A single response model or a list of them.

  • deep_copy – When true, return deep-copied dicts.

Returns:

A dict for a single input, or a list of dicts for a list input.