From bb4de91ac918b4befe9cbd4e260ae1b5c7b80b77 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Tue, 3 Feb 2026 17:12:42 -0400 Subject: [PATCH 1/2] Require typing_extensions on Python < 3.13 On newer Python releases, the typing module has all we need. Fixes: #189 --- 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 @@ 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 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] From 08f8e3b4341b7a11d34571c82f4b459e9279fe22 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Tue, 3 Feb 2026 17:44:16 -0400 Subject: [PATCH 2/2] Changelog entry --- docs/changelog.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 1e2c5c0..e60c61c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,12 @@ Changelog ========= +Unreleased +----------- +- Require `typing_extensions` on older Python versions (and use `typing` + on newer versions). [#189](https://github.com/beetbox/confuse/issues/189) + + v2.2.0 ------