From d3de202a944665fbc7b2b23abaa0aeb9cd569a73 Mon Sep 17 00:00:00 2001 From: kylejcaron Date: Tue, 12 Aug 2025 08:08:55 -0400 Subject: [PATCH 1/4] added >=py310 compatibility --- pyproject.toml | 3 ++- src/docstub/_cache.py | 7 ++++--- src/docstub/_config.py | 3 ++- tests/test_docs.py | 2 +- tox.ini | 18 ++++++++++++++++++ 5 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 tox.ini diff --git a/pyproject.toml b/pyproject.toml index 57a0855..8841582 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ readme = "README.md" license = "BSD-3-Clause AND PSF-2.0" license-files = ["LICENSE.txt"] -requires-python = ">=3.12" +requires-python = ">=3.9" keywords = ["typing", "stub files", "docstings", "numpydoc"] classifiers = [ "Development Status :: 3 - Alpha", @@ -38,6 +38,7 @@ dependencies = [ "lark >=1.1.9", "black >=24.4.2", "isort >=5.13.2", + "typing_extensions >= 4.5.0" ] [project.optional-dependencies] diff --git a/src/docstub/_cache.py b/src/docstub/_cache.py index e7a9f31..4843a1d 100644 --- a/src/docstub/_cache.py +++ b/src/docstub/_cache.py @@ -1,10 +1,11 @@ import logging from functools import cached_property -from typing import Any, Protocol -logger = logging.getLogger(__name__) +from typing_extensions import Any, Protocol, TypeVar +logger = logging.getLogger(__name__) +T = TypeVar("T") CACHE_DIR_NAME = ".docstub_cache" @@ -92,7 +93,7 @@ def validate_cache(path): raise FileNotFoundError(f"expected '{path}' to contain a '.gitignore' file") -class FuncSerializer[T](Protocol): +class FuncSerializer(Protocol[T]): """Defines an interface to serialize and deserialize results of a function. This interface is used by `FileCache` to cache results of a diff --git a/src/docstub/_config.py b/src/docstub/_config.py index e187041..0ad90e4 100644 --- a/src/docstub/_config.py +++ b/src/docstub/_config.py @@ -1,9 +1,10 @@ import dataclasses import logging -import tomllib from pathlib import Path from typing import ClassVar +import tomllib + logger = logging.getLogger(__name__) diff --git a/tests/test_docs.py b/tests/test_docs.py index ea64f50..4b65884 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -70,7 +70,7 @@ def test_command_line_reference(command, name): with md_file.open("r") as io: md_content = io.read() - guard_name = f"cli-{name.replace(" ", "-")}" + guard_name = f"cli-{name.replace(' ', '-')}" regex = rf"(.*)" matches = re.findall(regex, md_content, flags=re.DOTALL) assert len(matches) == 1 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..755e144 --- /dev/null +++ b/tox.ini @@ -0,0 +1,18 @@ +[tox] +envlist = check, python3.10, python3.11, python3.12 + +[testenv] +deps = pytest +commands = + pip install -e . + pytest tests + +[testenv:check] +description = perform style checks +extras = + dev, test +allowlist_externals = + pre-commit +commands = + pre-commit install + pre-commit run --all-files --show-diff-on-failure From 2c43f3c6e81eeb87129c018cce22932805a33280 Mon Sep 17 00:00:00 2001 From: kylejcaron Date: Tue, 12 Aug 2025 09:06:00 -0400 Subject: [PATCH 2/4] updated python >= 310 in pyproject and ci.yml --- .github/workflows/ci.yml | 2 +- pyproject.toml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3b6abc..d806391 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: - { short: linux, name: ubuntu-latest } - { short: win, name: windows-latest } - { short: macos, name: macos-14 } - python-version: ["3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 diff --git a/pyproject.toml b/pyproject.toml index 8841582..fb353af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ readme = "README.md" license = "BSD-3-Clause AND PSF-2.0" license-files = ["LICENSE.txt"] -requires-python = ">=3.9" +requires-python = ">=3.10" keywords = ["typing", "stub files", "docstings", "numpydoc"] classifiers = [ "Development Status :: 3 - Alpha", @@ -25,6 +25,8 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Topic :: Software Development :: Code Generators", From b951ba5c52e03524303a51c6875b7dc4efc34cbe Mon Sep 17 00:00:00 2001 From: kylejcaron Date: Tue, 12 Aug 2025 09:13:51 -0400 Subject: [PATCH 3/4] removed tox.ini --- tox.ini | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 tox.ini diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 755e144..0000000 --- a/tox.ini +++ /dev/null @@ -1,18 +0,0 @@ -[tox] -envlist = check, python3.10, python3.11, python3.12 - -[testenv] -deps = pytest -commands = - pip install -e . - pytest tests - -[testenv:check] -description = perform style checks -extras = - dev, test -allowlist_externals = - pre-commit -commands = - pre-commit install - pre-commit run --all-files --show-diff-on-failure From f27ae399886c1a6381e5ab2d058469592dac30a9 Mon Sep 17 00:00:00 2001 From: kylejcaron Date: Tue, 12 Aug 2025 09:15:57 -0400 Subject: [PATCH 4/4] restored _config to original version --- src/docstub/_config.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/docstub/_config.py b/src/docstub/_config.py index 0ad90e4..e187041 100644 --- a/src/docstub/_config.py +++ b/src/docstub/_config.py @@ -1,10 +1,9 @@ import dataclasses import logging +import tomllib from pathlib import Path from typing import ClassVar -import tomllib - logger = logging.getLogger(__name__)