From 512bf3e1c62431867736bd36f8603cddacb615e5 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Mon, 28 Sep 2020 08:12:40 -0700 Subject: [PATCH] cleanup: docstrings to type annotations --- hyperglass/encode.py | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/hyperglass/encode.py b/hyperglass/encode.py index 6ca94ed2..3b476acf 100644 --- a/hyperglass/encode.py +++ b/hyperglass/encode.py @@ -10,20 +10,8 @@ from hyperglass.exceptions import RestError -async def jwt_decode(payload, secret): - """Decode & validate an encoded JSON Web Token (JWT). - - Arguments: - payload {str} -- Raw JWT payload - secret {str} -- JWT secret - - Raises: - RestError: Raised if decoded payload is improperly formatted - or if the JWT is not able to be decoded. - - Returns: - {str} -- Decoded response payload - """ +async def jwt_decode(payload: str, secret: str) -> str: + """Decode & validate an encoded JSON Web Token (JWT).""" try: decoded = jwt.decode(payload, secret, algorithm="HS256") decoded = decoded["payload"] @@ -32,17 +20,8 @@ async def jwt_decode(payload, secret): raise RestError(str(exp)) from None -async def jwt_encode(payload, secret, duration): - """Encode a query to a JSON Web Token (JWT). - - Arguments: - payload {str} -- Stringified JSON request - secret {str} -- JWT secret - duration {int} -- Number of seconds claim is valid - - Returns: - str -- Encoded request payload - """ +async def jwt_encode(payload: str, secret: str, duration: int) -> str: + """Encode a query to a JSON Web Token (JWT).""" token = { "payload": payload, "nbf": datetime.datetime.utcnow(),