From bf6444106c7379e86dd03d79bc574d4e4a204d96 Mon Sep 17 00:00:00 2001 From: Arnav Borborah Date: Fri, 20 Mar 2020 19:41:08 -0400 Subject: [PATCH 1/2] Start documenting get function --- pypokedex/api.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pypokedex/api.py b/pypokedex/api.py index 32a2fc8..46c68f2 100644 --- a/pypokedex/api.py +++ b/pypokedex/api.py @@ -11,6 +11,18 @@ @lru_cache(maxsize=None) def get(**kwargs) -> Pokemon: + """Get a Pokemon object based on exactly ONE of the criteria specified + in the keyword argument ``kwargs``. + + :param name: The name of the Pokemon + :type name: str: + + :param dex: The national Pokedex number of the Pokemon. + :type name: int: + + :return: An instance of a :class:`Pokemon` if no errors occurred. + """ + if len(kwargs) != 1: raise TypeError("pypokedex.get() expects expects only 1 argument!") From a5e16140ffb3c566aefb66c6545cc5ad61166952 Mon Sep 17 00:00:00 2001 From: Arnav Borborah Date: Sat, 21 Mar 2020 15:10:33 -0400 Subject: [PATCH 2/2] Finish documenting get function --- pypokedex/api.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pypokedex/api.py b/pypokedex/api.py index 46c68f2..efc8b1e 100644 --- a/pypokedex/api.py +++ b/pypokedex/api.py @@ -12,15 +12,23 @@ @lru_cache(maxsize=None) def get(**kwargs) -> Pokemon: """Get a Pokemon object based on exactly ONE of the criteria specified - in the keyword argument ``kwargs``. + in the keyword argument ``kwargs`` - :param name: The name of the Pokemon + :key name: The name of the Pokemon :type name: str: - :param dex: The national Pokedex number of the Pokemon. + :key dex: The national Pokedex number of the Pokemon :type name: int: - :return: An instance of a :class:`Pokemon` if no errors occurred. + :raises TypeError: if exactly one argument isn't passed, ``dex`` or ``name`` + are of the wrong types, or if they aren't prresent + :raises PyPokedexHTTPError: if an non-success HTTP status code is returned + from PokeAPI while retrieving Pokemon data + :raises PyPokedexError: if an unexpected HTTP error occurs while retrieving + Pokemon data + + :return: An instance of a :class:`Pokemon` fitting the passed criteria + if no errors occurred """ if len(kwargs) != 1: