From 6c4ffeee01af51c0a9df4dda2618f79c1eda1f06 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Thu, 11 Jan 2024 20:55:30 +0100 Subject: [PATCH] Make `typing-extensions` optional again (#2409) --- starlette/applications.py | 6 +++++- starlette/middleware/__init__.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/starlette/applications.py b/starlette/applications.py index 3e1086d98..c3afaf704 100644 --- a/starlette/applications.py +++ b/starlette/applications.py @@ -1,9 +1,13 @@ from __future__ import annotations +import sys import typing import warnings -from typing_extensions import ParamSpec +if sys.version_info >= (3, 10): # pragma: no cover + from typing import ParamSpec +else: # pragma: no cover + from typing_extensions import ParamSpec from starlette.datastructures import State, URLPath from starlette.middleware import Middleware, _MiddlewareClass diff --git a/starlette/middleware/__init__.py b/starlette/middleware/__init__.py index 880e301eb..ca9752baa 100644 --- a/starlette/middleware/__init__.py +++ b/starlette/middleware/__init__.py @@ -1,6 +1,10 @@ +import sys from typing import Any, Iterator, Protocol, Type -from typing_extensions import ParamSpec +if sys.version_info >= (3, 10): # pragma: no cover + from typing import ParamSpec +else: # pragma: no cover + from typing_extensions import ParamSpec from starlette.types import ASGIApp, Receive, Scope, Send