File: 0001-Require-typing_extensions-on-Python-3.13.patch

package info (click to toggle)
python-confuse 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 652 kB
  • sloc: python: 3,065; makefile: 112; sh: 8
file content (68 lines) | stat: -rw-r--r-- 1,880 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From: Stefano Rivera <stefano@rivera.za.net>
Date: Tue, 3 Feb 2026 17:12:42 -0400
Subject: Require typing_extensions on Python < 3.13

On newer Python releases, the typing module has all we need.

Fixes: #189

Bug-Upstream: https://github.com/beetbox/confuse/issues/189
Forwarded: https://github.com/beetbox/confuse/pull/193
---
 confuse/core.py      | 6 +++++-
 confuse/templates.py | 6 +++++-
 pyproject.toml       | 1 +
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/confuse/core.py b/confuse/core.py
index 41cb5d6..d1b117e 100644
--- a/confuse/core.py
+++ b/confuse/core.py
@@ -33,8 +33,12 @@ import os
 from collections import OrderedDict
 from typing import TYPE_CHECKING, Any, TypeVar, overload
 
+try:
+    from typing import Self
+except ImportError:  # Python < 3.11
+    from typing_extensions import Self
+
 import yaml
-from typing_extensions import Self
 
 from . import templates, util, yaml_util
 from .exceptions import ConfigError, ConfigTypeError, NotFoundError
diff --git a/confuse/templates.py b/confuse/templates.py
index 55bbd7c..a706765 100644
--- a/confuse/templates.py
+++ b/confuse/templates.py
@@ -4,12 +4,16 @@ import enum
 import os
 import pathlib
 import re
+import sys
 from collections import abc
 from collections.abc import Hashable, Iterable, Mapping
 from functools import singledispatchmethod
 from typing import TYPE_CHECKING, Any, Generic, NoReturn, overload
 
-from typing_extensions import TypeVar
+if sys.version_info < (3, 13):
+    from typing_extensions import TypeVar
+else:
+    from typing import TypeVar
 
 from . import exceptions, util
 
diff --git a/pyproject.toml b/pyproject.toml
index cbf03c9..835f816 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -18,6 +18,7 @@ classifiers = [
 ]
 dependencies = [
     "pyyaml",
+    "typing_extensions >= 4.4; python_version < '1.13'",
 ]
 
 [dependency-groups]