diff --git a/pygeoapi/api/__init__.py b/pygeoapi/api/__init__.py index e764db2..ac641bd 100644 --- a/pygeoapi/api/__init__.py +++ b/pygeoapi/api/__init__.py @@ -198,7 +198,7 @@ def gzip(func): return inner -def apply_gzip(headers: dict, content: str | bytes) -> str | bytes: +def apply_gzip(headers: dict, content: Union[str, bytes]) -> Union[str, bytes]: """ Compress content if requested in header. """ diff --git a/pygeoapi/django_/views.py b/pygeoapi/django_/views.py index fe841b2..f214d2b 100644 --- a/pygeoapi/django_/views.py +++ b/pygeoapi/django_/views.py @@ -35,7 +35,7 @@ """Integration module for Django""" -from typing import Tuple, Dict, Mapping, Optional +from typing import Tuple, Dict, Mapping, Optional, Union from django.conf import settings from django.http import HttpRequest, HttpResponse @@ -562,7 +562,7 @@ def execute_from_django(api_function, request: HttpRequest, *args, api_ = API(settings.PYGEOAPI_CONFIG, settings.OPENAPI_DOCUMENT) api_request = APIRequest.from_django(request, api_.locales) - content: str | bytes + content: Union[str, bytes] if not skip_valid_check and not api_request.is_valid(): headers, status, content = api_.get_format_exception(api_request) else: @@ -575,7 +575,7 @@ def execute_from_django(api_function, request: HttpRequest, *args, # TODO: inline this to execute_from_django after refactoring def _to_django_response(headers: Mapping, status_code: int, - content: str | bytes) -> HttpResponse: + content: Union[str, bytes]) -> HttpResponse: """Convert API payload to a django response""" response = HttpResponse(content, status=status_code) diff --git a/pygeoapi/flask_app.py b/pygeoapi/flask_app.py index e4d8e82..2153329 100644 --- a/pygeoapi/flask_app.py +++ b/pygeoapi/flask_app.py @@ -31,9 +31,9 @@ """Flask module providing the route paths to the api""" import os +from typing import Union import click - from flask import (Flask, Blueprint, make_response, request, send_from_directory, Response, Request) @@ -152,7 +152,7 @@ def execute_from_flask(api_function, request: Request, *args, api_request = APIRequest.from_flask(request, api_.locales) - content: str | bytes + content: Union[str, bytes] if not skip_valid_check and not api_request.is_valid(): headers, status, content = api_.get_format_exception(api_request) diff --git a/pygeoapi/starlette_app.py b/pygeoapi/starlette_app.py index 6d6b705..c0a9b7a 100644 --- a/pygeoapi/starlette_app.py +++ b/pygeoapi/starlette_app.py @@ -38,7 +38,6 @@ from typing import Callable, Union from pathlib import Path import click - from starlette.routing import Route, Mount from starlette.staticfiles import StaticFiles from starlette.applications import Starlette @@ -142,7 +141,7 @@ def _to_response(headers, status, content): async def execute_from_starlette(api_function, request: Request, *args, skip_valid_check=False) -> Response: api_request = await APIRequest.from_starlette(request, api_.locales) - content: str | bytes + content: Union[str, bytes] if not skip_valid_check and not api_request.is_valid(): headers, status, content = api_.get_format_exception(api_request) else: