From 4f93c1ede275922fa5e49abbd8b1c7f5eee8b5bc Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Tue, 3 Feb 2026 17:12:42 -0400 Subject: [PATCH] Require typing_extensions on Python < 3.13 On newer Python releases, the typing module has all we need. Fixes: #189 --- confuse/core.py | 7 ++++++- confuse/templates.py | 6 +++++- docs/changelog.rst | 6 ++++++ poetry.lock | 8 ++++---- pyproject.toml | 1 + 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/confuse/core.py b/confuse/core.py index 41cb5d6..e8d5e8b 100644 --- a/confuse/core.py +++ b/confuse/core.py @@ -30,11 +30,16 @@ import errno import os +import sys from collections import OrderedDict from typing import TYPE_CHECKING, Any, TypeVar, overload +if sys.version_info < (3, 11): + from typing_extensions import Self +else: + from typing 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/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 ------ diff --git a/poetry.lock b/poetry.lock index a4127ab..bdfa13b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.3.2 and should not be changed by hand. [[package]] name = "alabaster" @@ -1715,12 +1715,12 @@ version = "4.15.0" description = "Backported and Experimental Type Hints for Python 3.9+" optional = false python-versions = ">=3.9" -groups = ["dev", "lint"] +groups = ["main", "dev", "lint"] files = [ {file = "typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"}, {file = "typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"}, ] -markers = {dev = "python_version == \"3.10\""} +markers = {main = "python_version < \"3.13\"", dev = "python_version == \"3.10\""} [[package]] name = "urllib3" @@ -1747,4 +1747,4 @@ docs = ["sphinx", "sphinx-rtd-theme"] [metadata] lock-version = "2.1" python-versions = ">=3.10" -content-hash = "a66b26695a7b01066dcc6a13ae4fe8a2b09cf25853594d2b6adc3a63dcbdf4ac" +content-hash = "771acf375f1d6d25e7d1c4755abbfa0004509020c9ee51620d277fe2d25da845" diff --git a/pyproject.toml b/pyproject.toml index cbf03c9..97299fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ classifiers = [ ] dependencies = [ "pyyaml", + "typing_extensions >= 4.4; python_version < '3.13'", ] [dependency-groups]