patchy 2.9.0__tar.gz → 2.10.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {patchy-2.9.0 → patchy-2.10.0}/CHANGELOG.rst +5 -0
- {patchy-2.9.0/src/patchy.egg-info → patchy-2.10.0}/PKG-INFO +6 -4
- {patchy-2.9.0 → patchy-2.10.0}/README.rst +1 -1
- {patchy-2.9.0 → patchy-2.10.0}/pyproject.toml +49 -9
- {patchy-2.9.0 → patchy-2.10.0}/src/patchy/api.py +10 -24
- {patchy-2.9.0 → patchy-2.10.0/src/patchy.egg-info}/PKG-INFO +6 -4
- {patchy-2.9.0 → patchy-2.10.0}/tests/test_patch.py +3 -3
- {patchy-2.9.0 → patchy-2.10.0}/LICENSE +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/MANIFEST.in +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/pirate.png +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/setup.cfg +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/src/patchy/__init__.py +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/src/patchy/cache.py +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/src/patchy/py.typed +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/src/patchy.egg-info/SOURCES.txt +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/src/patchy.egg-info/dependency_links.txt +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/src/patchy.egg-info/top_level.txt +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/tests/test_cache.py +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/tests/test_patch_then_unpatch.py +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/tests/test_replace.py +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/tests/test_temp_patch.py +0 -0
- {patchy-2.9.0 → patchy-2.10.0}/tests/test_unpatch.py +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: patchy
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.10.0
|
|
4
4
|
Summary: Patch the inner source of python functions at runtime.
|
|
5
5
|
Author-email: Adam Johnson <me@adamj.eu>
|
|
6
|
+
License-Expression: MIT
|
|
6
7
|
Project-URL: Changelog, https://github.com/adamchainz/patchy/blob/main/CHANGELOG.rst
|
|
7
8
|
Project-URL: Funding, https://adamj.eu/books/
|
|
8
9
|
Project-URL: Repository, https://github.com/adamchainz/patchy
|
|
9
10
|
Keywords: patchy
|
|
10
11
|
Classifier: Development Status :: 5 - Production/Stable
|
|
11
12
|
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
13
|
Classifier: Natural Language :: English
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
15
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
@@ -18,10 +18,12 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
22
|
Classifier: Typing :: Typed
|
|
22
23
|
Requires-Python: >=3.9
|
|
23
24
|
Description-Content-Type: text/x-rst
|
|
24
25
|
License-File: LICENSE
|
|
26
|
+
Dynamic: license-file
|
|
25
27
|
|
|
26
28
|
======
|
|
27
29
|
Patchy
|
|
@@ -90,7 +92,7 @@ Use **pip**:
|
|
|
90
92
|
|
|
91
93
|
python -m pip install patchy
|
|
92
94
|
|
|
93
|
-
Python 3.9 to 3.
|
|
95
|
+
Python 3.9 to 3.14 supported.
|
|
94
96
|
|
|
95
97
|
Why?
|
|
96
98
|
====
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
[build-system]
|
|
2
2
|
build-backend = "setuptools.build_meta"
|
|
3
3
|
requires = [
|
|
4
|
-
"setuptools",
|
|
4
|
+
"setuptools>=77",
|
|
5
5
|
]
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "patchy"
|
|
9
|
-
version = "2.
|
|
9
|
+
version = "2.10.0"
|
|
10
10
|
description = "Patch the inner source of python functions at runtime."
|
|
11
11
|
readme = "README.rst"
|
|
12
12
|
keywords = [
|
|
13
13
|
"patchy",
|
|
14
14
|
]
|
|
15
|
+
license = "MIT"
|
|
16
|
+
license-files = [ "LICENSE" ]
|
|
15
17
|
authors = [
|
|
16
18
|
{ name = "Adam Johnson", email = "me@adamj.eu" },
|
|
17
19
|
]
|
|
@@ -19,7 +21,6 @@ requires-python = ">=3.9"
|
|
|
19
21
|
classifiers = [
|
|
20
22
|
"Development Status :: 5 - Production/Stable",
|
|
21
23
|
"Intended Audience :: Developers",
|
|
22
|
-
"License :: OSI Approved :: MIT License",
|
|
23
24
|
"Natural Language :: English",
|
|
24
25
|
"Operating System :: OS Independent",
|
|
25
26
|
"Programming Language :: Python :: 3 :: Only",
|
|
@@ -28,20 +29,59 @@ classifiers = [
|
|
|
28
29
|
"Programming Language :: Python :: 3.11",
|
|
29
30
|
"Programming Language :: Python :: 3.12",
|
|
30
31
|
"Programming Language :: Python :: 3.13",
|
|
32
|
+
"Programming Language :: Python :: 3.14",
|
|
31
33
|
"Typing :: Typed",
|
|
32
34
|
]
|
|
33
35
|
dependencies = [ ]
|
|
34
36
|
urls = { Changelog = "https://github.com/adamchainz/patchy/blob/main/CHANGELOG.rst", Funding = "https://adamj.eu/books/", Repository = "https://github.com/adamchainz/patchy" }
|
|
35
37
|
|
|
36
|
-
[
|
|
37
|
-
|
|
38
|
-
"
|
|
38
|
+
[dependency-groups]
|
|
39
|
+
test = [
|
|
40
|
+
"coverage[toml]",
|
|
41
|
+
"pkgutil-resolve-name; python_version<'3.9'",
|
|
42
|
+
"pytest",
|
|
43
|
+
"pytest-randomly",
|
|
39
44
|
]
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
|
|
46
|
+
[tool.ruff]
|
|
47
|
+
lint.select = [
|
|
48
|
+
# flake8-bugbear
|
|
49
|
+
"B",
|
|
50
|
+
# flake8-comprehensions
|
|
51
|
+
"C4",
|
|
52
|
+
# pycodestyle
|
|
53
|
+
"E",
|
|
54
|
+
# Pyflakes errors
|
|
55
|
+
"F",
|
|
56
|
+
# isort
|
|
57
|
+
"I",
|
|
58
|
+
# flake8-simplify
|
|
59
|
+
"SIM",
|
|
60
|
+
# flake8-tidy-imports
|
|
61
|
+
"TID",
|
|
62
|
+
# pyupgrade
|
|
63
|
+
"UP",
|
|
64
|
+
# Pyflakes warnings
|
|
65
|
+
"W",
|
|
66
|
+
]
|
|
67
|
+
lint.ignore = [
|
|
68
|
+
# flake8-bugbear opinionated rules
|
|
69
|
+
"B9",
|
|
70
|
+
# line-too-long
|
|
71
|
+
"E501",
|
|
72
|
+
# suppressible-exception
|
|
73
|
+
"SIM105",
|
|
74
|
+
# if-else-block-instead-of-if-exp
|
|
75
|
+
"SIM108",
|
|
76
|
+
]
|
|
77
|
+
lint.extend-safe-fixes = [
|
|
78
|
+
# non-pep585-annotation
|
|
79
|
+
"UP006",
|
|
80
|
+
]
|
|
81
|
+
lint.isort.required-imports = [ "from __future__ import annotations" ]
|
|
42
82
|
|
|
43
83
|
[tool.pyproject-fmt]
|
|
44
|
-
max_supported_python = "3.
|
|
84
|
+
max_supported_python = "3.14"
|
|
45
85
|
|
|
46
86
|
[tool.pytest.ini_options]
|
|
47
87
|
addopts = """\
|
|
@@ -8,12 +8,8 @@ import subprocess
|
|
|
8
8
|
from functools import wraps
|
|
9
9
|
from tempfile import mkdtemp
|
|
10
10
|
from textwrap import dedent
|
|
11
|
-
from types import CodeType
|
|
12
|
-
from
|
|
13
|
-
from typing import Any
|
|
14
|
-
from typing import Callable
|
|
15
|
-
from typing import TypeVar
|
|
16
|
-
from typing import cast
|
|
11
|
+
from types import CodeType, TracebackType
|
|
12
|
+
from typing import Any, Callable, TypeVar, cast
|
|
17
13
|
from weakref import WeakKeyDictionary
|
|
18
14
|
|
|
19
15
|
from .cache import PatchingCache
|
|
@@ -141,12 +137,8 @@ def _apply_patch(
|
|
|
141
137
|
prep=("to" if forwards else "from"),
|
|
142
138
|
name=name,
|
|
143
139
|
)
|
|
144
|
-
msg += " The message from `patch` was:\n{}\n{}"
|
|
145
|
-
|
|
146
|
-
)
|
|
147
|
-
msg += "\nThe code to patch was:\n{}\nThe patch was:\n{}".format(
|
|
148
|
-
source, patch_text
|
|
149
|
-
)
|
|
140
|
+
msg += f" The message from `patch` was:\n{result.stdout}\n{result.stderr}"
|
|
141
|
+
msg += f"\nThe code to patch was:\n{source}\nThe patch was:\n{patch_text}"
|
|
150
142
|
raise ValueError(msg)
|
|
151
143
|
|
|
152
144
|
with open(source_path) as source_file:
|
|
@@ -271,12 +263,8 @@ def _set_source(func: Callable[..., Any], func_source: str) -> None:
|
|
|
271
263
|
if class_name in func.__code__.co_freevars
|
|
272
264
|
else f" global {class_name}\n"
|
|
273
265
|
)
|
|
274
|
-
class_src = "{_global} class {
|
|
275
|
-
|
|
276
|
-
)
|
|
277
|
-
ret = " return {class_name}.{name}".format(
|
|
278
|
-
class_name=class_name, name=func.__name__
|
|
279
|
-
)
|
|
266
|
+
class_src = f"{_global} class {class_name}(object):\n pass"
|
|
267
|
+
ret = f" return {class_name}.{func.__name__}"
|
|
280
268
|
to_parse = "\n".join([_def] + fv_body + [class_src, ret])
|
|
281
269
|
new_source = _parse(to_parse)
|
|
282
270
|
new_source.body[0].body[-2].body[0] = _ast # type: ignore [attr-defined]
|
|
@@ -330,12 +318,10 @@ def _get_real_func(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
|
330
318
|
def _assert_ast_equal(current_source: str, expected_source: str, name: str) -> None:
|
|
331
319
|
current_ast = ast.parse(current_source)
|
|
332
320
|
expected_ast = ast.parse(expected_source)
|
|
333
|
-
if
|
|
321
|
+
if ast.dump(current_ast) != ast.dump(expected_ast):
|
|
334
322
|
msg = (
|
|
335
|
-
"The code of '{name}' has changed from expected.\n"
|
|
336
|
-
"The current code is:\n{current_source}\n"
|
|
337
|
-
"The expected code is:\n{expected_source}"
|
|
338
|
-
).format(
|
|
339
|
-
name=name, current_source=current_source, expected_source=expected_source
|
|
323
|
+
f"The code of '{name}' has changed from expected.\n"
|
|
324
|
+
f"The current code is:\n{current_source}\n"
|
|
325
|
+
f"The expected code is:\n{expected_source}"
|
|
340
326
|
)
|
|
341
327
|
raise ValueError(msg)
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: patchy
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.10.0
|
|
4
4
|
Summary: Patch the inner source of python functions at runtime.
|
|
5
5
|
Author-email: Adam Johnson <me@adamj.eu>
|
|
6
|
+
License-Expression: MIT
|
|
6
7
|
Project-URL: Changelog, https://github.com/adamchainz/patchy/blob/main/CHANGELOG.rst
|
|
7
8
|
Project-URL: Funding, https://adamj.eu/books/
|
|
8
9
|
Project-URL: Repository, https://github.com/adamchainz/patchy
|
|
9
10
|
Keywords: patchy
|
|
10
11
|
Classifier: Development Status :: 5 - Production/Stable
|
|
11
12
|
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
13
|
Classifier: Natural Language :: English
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
15
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
@@ -18,10 +18,12 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
22
|
Classifier: Typing :: Typed
|
|
22
23
|
Requires-Python: >=3.9
|
|
23
24
|
Description-Content-Type: text/x-rst
|
|
24
25
|
License-File: LICENSE
|
|
26
|
+
Dynamic: license-file
|
|
25
27
|
|
|
26
28
|
======
|
|
27
29
|
Patchy
|
|
@@ -90,7 +92,7 @@ Use **pip**:
|
|
|
90
92
|
|
|
91
93
|
python -m pip install patchy
|
|
92
94
|
|
|
93
|
-
Python 3.9 to 3.
|
|
95
|
+
Python 3.9 to 3.14 supported.
|
|
94
96
|
|
|
95
97
|
Why?
|
|
96
98
|
====
|
|
@@ -862,13 +862,13 @@ def test_patch_future_instancemethod(tmp_path):
|
|
|
862
862
|
|
|
863
863
|
|
|
864
864
|
def test_patch_nonlocal_fails():
|
|
865
|
-
variab = 20
|
|
865
|
+
variab = 20 # noqa: F841
|
|
866
866
|
|
|
867
867
|
def get_function() -> Callable[[], int]:
|
|
868
868
|
variab = 15
|
|
869
869
|
|
|
870
870
|
def sample() -> int:
|
|
871
|
-
nonlocal variab
|
|
871
|
+
nonlocal variab # noqa: F824
|
|
872
872
|
multiple = 3
|
|
873
873
|
return variab * multiple
|
|
874
874
|
|
|
@@ -882,7 +882,7 @@ def test_patch_nonlocal_fails():
|
|
|
882
882
|
sample,
|
|
883
883
|
"""\
|
|
884
884
|
@@ -2,3 +2,3 @@
|
|
885
|
-
nonlocal variab
|
|
885
|
+
nonlocal variab # noqa: F824
|
|
886
886
|
- multiple = 3
|
|
887
887
|
+ multiple = 4
|
|
888
888
|
""",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|