Skip to content

Commit 3126eaa

Browse files
fix: support Python 3.11 to prevent squatter install (#107)
* fix: support Python 3.11 to prevent squatter install On Python 3.11, `pip install pympp` was installing version 0.0.1 (a name squatter) because requires-python >= 3.12 caused pip to skip all real versions. - Lower requires-python to >= 3.11 (datetime.UTC and X|Y unions work on 3.11) - Replace PEP 695 generic syntax (def func[R]) with TypeVar — the only 3.12-specific syntax in the codebase - Update ruff/pyright targets to py311 * chore: add changelog --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent bc87d6d commit 3126eaa

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

.changelog/plain-mules-fix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
pympp: patch
3+
---
4+
5+
Added Python 3.11 support by lowering the `requires-python` constraint from `>=3.12` to `>=3.11`, updating tooling targets accordingly, and replacing PEP 695 generic syntax with `TypeVar` for compatibility.

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "pympp"
33
version = "0.5.2"
44
description = "Python SDK for the Machine Payments Protocol (MPP)"
55
readme = "README.md"
6-
requires-python = ">=3.12"
6+
requires-python = ">=3.11"
77
dependencies = [
88
"httpx>=0.27",
99
]
@@ -15,6 +15,7 @@ classifiers = [
1515
"License :: OSI Approved :: MIT License",
1616
"License :: OSI Approved :: Apache Software License",
1717
"Programming Language :: Python :: 3 :: Only",
18+
"Programming Language :: Python :: 3.11",
1819
"Programming Language :: Python :: 3.12",
1920
"Programming Language :: Python :: 3.13",
2021
"Typing :: Typed",
@@ -68,7 +69,7 @@ packages = ["src/mpp"]
6869

6970
[tool.ruff]
7071
line-length = 100
71-
target-version = "py312"
72+
target-version = "py311"
7273
exclude = ["examples"]
7374

7475
[tool.ruff.lint]
@@ -82,7 +83,7 @@ ignore = []
8283
quote-style = "double"
8384

8485
[tool.pyright]
85-
pythonVersion = "3.12"
86+
pythonVersion = "3.11"
8687
typeCheckingMode = "standard"
8788
include = ["src", "tests"]
8889

src/mpp/server/decorator.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import json as _json
77
from collections.abc import Awaitable, Callable
88
from functools import wraps
9-
from typing import TYPE_CHECKING, Any
9+
from typing import TYPE_CHECKING, Any, TypeVar
1010

1111
from mpp import Challenge, Credential, Receipt
1212
from mpp.errors import PaymentRequiredError
@@ -16,6 +16,8 @@
1616
if TYPE_CHECKING:
1717
from mpp.server.intent import Intent
1818

19+
R = TypeVar("R")
20+
1921
RequestParamsType = dict[str, Any] | Callable[[Any], dict[str, Any]]
2022

2123

@@ -63,7 +65,7 @@ def make_challenge_response(challenge: Challenge, realm: str) -> Any:
6365
}
6466

6567

66-
def wrap_payment_handler[R](
68+
def wrap_payment_handler(
6769
handler: Callable[..., Awaitable[R]],
6870
verify_fn: Callable[[str | None, Any], Awaitable[Challenge | tuple[Credential, Receipt]]],
6971
realm_fn: Callable[[], str],
@@ -117,7 +119,7 @@ async def wrapper(*args: Any, **kwargs: Any) -> R | Any:
117119
return wrapper
118120

119121

120-
def pay[R](
122+
def pay(
121123
*,
122124
intent: Intent,
123125
request: RequestParamsType,

0 commit comments

Comments
 (0)