Skip to content

Commit

Permalink
Issue #460 use typing.NamedTuple in oidc.py
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Aug 28, 2023
1 parent 86c418b commit 165c449
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
31 changes: 18 additions & 13 deletions openeo/rest/auth/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
import inspect
import json
import logging
import math
import random
import string
import threading
import time
import urllib.parse
import warnings
import webbrowser
from collections import namedtuple
from queue import Empty, Queue
from typing import Callable, List, Optional, Tuple, Union
from typing import Callable, List, NamedTuple, Optional, Tuple, Union

import requests

Expand Down Expand Up @@ -200,11 +198,12 @@ class OidcException(OpenEoClientException):
pass


# Container for result of access_token request.
AccessTokenResult = namedtuple(
typename="AccessTokenResult",
field_names=["access_token", "id_token", "refresh_token"]
)
class AccessTokenResult(NamedTuple):
"""Container for result of access_token request."""

access_token: str
id_token: Optional[str] = None
refresh_token: Optional[str] = None


def jwt_decode(token: str) -> Tuple[dict, dict]:
Expand Down Expand Up @@ -451,7 +450,11 @@ def sha256_hash(code: str) -> str:
return base64.urlsafe_b64encode(data).decode('ascii').replace('=', '')


AuthCodeResult = namedtuple("AuthCodeResult", ["auth_code", "nonce", "code_verifier", "redirect_uri"])
class AuthCodeResult(NamedTuple):
auth_code: str
nonce: str
code_verifier: str
redirect_uri: str


class OidcAuthCodePkceAuthenticator(OidcAuthenticator):
Expand Down Expand Up @@ -664,10 +667,12 @@ def _get_token_endpoint_post_data(self) -> dict:
return data


VerificationInfo = namedtuple(
"VerificationInfo",
["verification_uri", "verification_uri_complete", "device_code", "user_code", "interval"]
)
class VerificationInfo(NamedTuple):
verification_uri: str
verification_uri_complete: Optional[str]
device_code: str
user_code: str
interval: int


def _like_print(display: Callable) -> Callable:
Expand Down
1 change: 0 additions & 1 deletion tests/udf/test_xarraydatacube.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import itertools
from typing import Union, Optional, List, Tuple, Iterator, NamedTuple
import collections
import numpy
import pytest
import xarray
Expand Down

0 comments on commit 165c449

Please sign in to comment.