Skip to content

Commit 71cbd00

Browse files
committed
Hah, nice, of course default= only exists in 3.13.
1 parent 5ea5a15 commit 71cbd00

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dynamic = ["version"]
3535
dependencies = [
3636
"attrs>=22.2.0",
3737
"rpds-py>=0.7.0",
38+
"typing-extensions; python_version<'3.13'",
3839
]
3940

4041
[project.urls]

referencing/_core.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
from collections.abc import Iterable, Iterator, Sequence
44
from enum import Enum
5-
from typing import Any, Callable, ClassVar, Generic, Protocol, TypeVar
5+
from typing import Any, Callable, ClassVar, Generic, Protocol
66
from urllib.parse import unquote, urldefrag, urljoin
77

88
from attrs import evolve, field
99
from rpds import HashTrieMap, HashTrieSet, List
1010

11+
try:
12+
from typing_extensions import TypeVar
13+
except ImportError:
14+
from typing import TypeVar
15+
1116
from referencing import exceptions
1217
from referencing._attrs import frozen
1318
from referencing.typing import URI, Anchor as AnchorType, D, Mapping, Retrieve
@@ -592,8 +597,9 @@ def resolver_with_root(self, resource: Resource[D]) -> Resolver[D]:
592597
#: An anchor or resource.
593598
AnchorOrResource = TypeVar(
594599
"AnchorOrResource",
595-
bound=AnchorType[Any] | Resource[Any],
596-
default=AnchorType[Any] | Resource[Any],
600+
AnchorType[Any],
601+
Resource[Any],
602+
default=Resource[Any],
597603
)
598604

599605

referencing/retrieval.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
from __future__ import annotations
66

77
from functools import lru_cache
8-
from typing import TYPE_CHECKING, Callable, TypeVar
8+
from typing import TYPE_CHECKING, Callable
99
import json
1010

11+
try:
12+
from typing_extensions import TypeVar
13+
except ImportError:
14+
from typing import TypeVar
15+
1116
from referencing import Resource
1217

1318
if TYPE_CHECKING:

referencing/typing.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
from __future__ import annotations
66

77
from collections.abc import Mapping as Mapping
8-
from typing import TYPE_CHECKING, Any, Protocol, TypeVar
8+
from typing import TYPE_CHECKING, Any, Protocol
9+
10+
try:
11+
from typing_extensions import TypeVar
12+
except ImportError:
13+
from typing import TypeVar
914

1015
if TYPE_CHECKING:
1116
from referencing._core import Resolved, Resolver, Resource

0 commit comments

Comments
 (0)