Skip to content

Commit 2af5adb

Browse files
pdecattimo-reymann
authored andcommitted
fix: restore python 3.9 compatibility
1 parent 9959801 commit 2af5adb

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

oauth2_cli_auth/_urllib_util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import time
33
import urllib
44
from urllib.error import URLError
5+
from typing import Union
56

67

78
def _urlopen_with_backoff(url, max_retries=3, base_delay=1, timeout=15):
@@ -19,7 +20,7 @@ def _urlopen_with_backoff(url, max_retries=3, base_delay=1, timeout=15):
1920
raise URLError(f"Failed to open URL after {max_retries} retries")
2021

2122

22-
def _load_json(url_or_request: str | urllib.request.Request) -> dict:
23+
def _load_json(url_or_request: Union[str, urllib.request.Request]) -> dict:
2324
with _urlopen_with_backoff(url_or_request) as response:
2425
response_data = response.read().decode('utf-8')
2526
json_response = json.loads(response_data)

oauth2_cli_auth/code_grant.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import webbrowser
88
from collections.abc import Callable
99
from dataclasses import dataclass
10+
from typing import Optional
1011

1112
from oauth2_cli_auth._urllib_util import _load_json
1213

@@ -58,7 +59,7 @@ def load_oidc_config(odic_well_known_endpoint: str) -> dict:
5859
return config
5960

6061

61-
def open_browser(url: str, print_open_browser_instruction: Callable[[str], None] | None = print) -> None:
62+
def open_browser(url: str, print_open_browser_instruction: Optional[Callable[[str], None]] = print) -> None:
6263
"""
6364
Open browser using webbrowser module and show message about URL open
6465

oauth2_cli_auth/http_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ class OAuthCallbackHttpServer(HTTPServer):
234234
def __init__(self, port):
235235
super().__init__(("", port), OAuthRedirectHandler)
236236

237-
self._code: str | None = None
237+
self._code: Optional[str] = None
238238

239-
def get_code(self) -> str | None:
239+
def get_code(self) -> Optional[str]:
240240
"""
241241
This method should only be called after the request was done and might be None when no token is given.
242242

0 commit comments

Comments
 (0)