python-extracontext 1.1.0__tar.gz → 1.2.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.
Files changed (26) hide show
  1. {python_extracontext-1.1.0/python_extracontext.egg-info → python_extracontext-1.2.0}/PKG-INFO +11 -4
  2. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/__init__.py +1 -1
  3. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/base.py +2 -2
  4. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/executor.py +14 -3
  5. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/mapping.py +3 -2
  6. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/pyproject.toml +24 -3
  7. {python_extracontext-1.1.0 → python_extracontext-1.2.0/python_extracontext.egg-info}/PKG-INFO +11 -4
  8. python_extracontext-1.2.0/python_extracontext.egg-info/requires.txt +12 -0
  9. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_executor.py +0 -2
  10. python_extracontext-1.1.0/python_extracontext.egg-info/requires.txt +0 -6
  11. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/LICENSE +0 -0
  12. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/README.md +0 -0
  13. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/_future_task.py +0 -0
  14. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/contextlocal.py +0 -0
  15. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/contextlocal_native.py +0 -0
  16. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/python_extracontext.egg-info/SOURCES.txt +0 -0
  17. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/python_extracontext.egg-info/dependency_links.txt +0 -0
  18. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/python_extracontext.egg-info/top_level.txt +0 -0
  19. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/setup.cfg +0 -0
  20. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_async.py +0 -0
  21. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_contextmanager.py +0 -0
  22. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_generators.py +0 -0
  23. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_mapping.py +0 -0
  24. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_pep550.py +0 -0
  25. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_plain.py +0 -0
  26. {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_thread.py +0 -0
@@ -1,17 +1,18 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-extracontext
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Context Variable namespaces supporting generators, asyncio and multi-threading
5
5
  Author: Joao S. O. Bueno
6
6
  Project-URL: repository, https://github.com/jsbueno/extracontext
7
+ Project-URL: documentation, https://jsbueno.github.io/extracontext/
7
8
  Classifier: Development Status :: 5 - Production/Stable
8
9
  Classifier: Intended Audience :: Developers
9
- Classifier: Programming Language :: Python :: 3.8
10
- Classifier: Programming Language :: Python :: 3.9
11
10
  Classifier: Programming Language :: Python :: 3.10
12
11
  Classifier: Programming Language :: Python :: 3.11
13
12
  Classifier: Programming Language :: Python :: 3.12
14
13
  Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: 3.15
15
16
  Classifier: Programming Language :: Python :: Implementation :: CPython
16
17
  Classifier: Programming Language :: Python :: Implementation :: PyPy
17
18
  Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
@@ -24,6 +25,12 @@ Requires-Dist: pytest; extra == "dev"
24
25
  Requires-Dist: black; extra == "dev"
25
26
  Requires-Dist: pyflakes; extra == "dev"
26
27
  Requires-Dist: pytest-coverage; extra == "dev"
28
+ Requires-Dist: pytest-timeout>=2.4.0; extra == "dev"
29
+ Provides-Extra: docs
30
+ Requires-Dist: mkdocs; extra == "docs"
31
+ Requires-Dist: mkdocs-material; extra == "docs"
32
+ Requires-Dist: mkdocstrings[python]; extra == "docs"
33
+ Dynamic: license-file
27
34
 
28
35
  # Extracontext: Context Local Variables for everyone
29
36
 
@@ -4,7 +4,7 @@ from .mapping import ContextMap
4
4
  from .contextlocal_native import NativeContextLocal
5
5
  from .executor import ContextPreservingExecutor
6
6
 
7
- __version__ = "1.1.0"
7
+ __version__ = "1.2.0"
8
8
 
9
9
  __all__ = [
10
10
  "ContextLocal",
@@ -1,8 +1,8 @@
1
- from typing import Self
1
+ # from typing import Self
2
2
 
3
3
 
4
4
  class ContextLocal:
5
- _backend_registry: dict[str, type[Self]] = {}
5
+ _backend_registry: dict[str, type["ContextLocal"]] = {}
6
6
 
7
7
  def __new__(cls, *args, backend=None, **kwargs):
8
8
  if backend is None:
@@ -31,11 +31,22 @@ class _CustomWorkItem(concurrent.futures.thread._WorkItem):
31
31
  super().__init__(*args, **kwargs)
32
32
  self._context = contextvars.copy_context()
33
33
 
34
- def run(self):
35
- ctx = self._context.copy()
36
- result = ctx.run(super().run)
34
+ def run(self, ctx=None):
35
+ context_vars_ctx = self._context.copy()
36
+ # Python 3.14: the signature for _WorkItem.run changed, and
37
+ # it now needs an intemediate object that is passed in the "ctx" parameter.
38
+ result = context_vars_ctx.run(super().run, *((ctx,) if ctx else () ))
37
39
  return result
38
40
 
41
+ import sys
42
+ """
43
+ There are some changes in Python 3.14 to copy the context of the original thread,
44
+ but it still won't work with a task-specific context
45
+
46
+ """
47
+ if sys.version_info >= (3,14):
48
+ pass
49
+
39
50
 
40
51
  original_submit = ThreadPoolExecutor.submit
41
52
  new_globals = concurrent.futures.thread.__dict__.copy()
@@ -1,4 +1,5 @@
1
1
  from collections.abc import Mapping, MutableMapping
2
+ from typing import Optional
2
3
 
3
4
  from .base import ContextLocal
4
5
  from .contextlocal import PyContextLocal
@@ -48,7 +49,7 @@ class PyContextMap(ContextMap, PyContextLocal):
48
49
  _backend_key = "python"
49
50
  _BASEDIST = 1
50
51
 
51
- def __init__(self, initial: None | Mapping = None, *, backend=None):
52
+ def __init__(self, initial: Optional[Mapping] = None, *, backend=None):
52
53
  super().__init__()
53
54
  if not initial:
54
55
  return
@@ -63,7 +64,7 @@ class PyContextMap(ContextMap, PyContextLocal):
63
64
  class NativeContextMap(ContextMap, NativeContextLocal):
64
65
  _backend_key = "native"
65
66
 
66
- def __init__(self, initial: None | Mapping = None, *, backend=None):
67
+ def __init__(self, initial: Optional[Mapping] = None, *, backend=None):
67
68
  super().__init__()
68
69
  if not initial:
69
70
  return
@@ -19,20 +19,23 @@ authors = [{ name = "Joao S. O. Bueno" }]
19
19
  classifiers = [
20
20
  "Development Status :: 5 - Production/Stable",
21
21
  "Intended Audience :: Developers",
22
- "Programming Language :: Python :: 3.8",
23
- "Programming Language :: Python :: 3.9",
24
22
  "Programming Language :: Python :: 3.10",
25
23
  "Programming Language :: Python :: 3.11",
26
24
  "Programming Language :: Python :: 3.12",
27
25
  "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ "Programming Language :: Python :: 3.15",
28
28
  "Programming Language :: Python :: Implementation :: CPython",
29
29
  "Programming Language :: Python :: Implementation :: PyPy",
30
30
  "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
31
31
  "Operating System :: OS Independent",
32
32
  ]
33
+ dependencies = [
34
+ ]
33
35
 
34
36
  [project.urls]
35
37
  repository = "https://github.com/jsbueno/extracontext"
38
+ documentation = "https://jsbueno.github.io/extracontext/"
36
39
 
37
40
 
38
41
  [project.optional-dependencies]
@@ -41,13 +44,31 @@ dev = [
41
44
  "black",
42
45
  "pyflakes",
43
46
  "pytest-coverage",
47
+ "pytest-timeout>=2.4.0",
48
+ ]
49
+
50
+ docs = [
51
+ "mkdocs",
52
+ "mkdocs-material",
53
+ "mkdocstrings[python]",
44
54
  ]
45
55
 
46
56
  [tool.pytest.ini_options]
57
+ timeout = 2
47
58
  testpaths = "tests"
48
59
  python_files = "test_*.py"
49
60
  python_functions = "test_*"
50
- addopts = "-v --doctest-modules"
61
+ addopts = "-v --doctest-modules"
62
+
63
+ [tool.tox]
64
+ legacy_tox_ini = """
65
+ [tox]
66
+ env_list = py310, py311, py312, py313, py314, pypy310, pypy311, py313t, py314t
67
+
68
+ [testenv]
69
+ extras = dev
70
+ commands = pytest
71
+ """
51
72
 
52
73
  [tool.mypy]
53
74
  mypy_path = "typecheck"
@@ -1,17 +1,18 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-extracontext
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Context Variable namespaces supporting generators, asyncio and multi-threading
5
5
  Author: Joao S. O. Bueno
6
6
  Project-URL: repository, https://github.com/jsbueno/extracontext
7
+ Project-URL: documentation, https://jsbueno.github.io/extracontext/
7
8
  Classifier: Development Status :: 5 - Production/Stable
8
9
  Classifier: Intended Audience :: Developers
9
- Classifier: Programming Language :: Python :: 3.8
10
- Classifier: Programming Language :: Python :: 3.9
11
10
  Classifier: Programming Language :: Python :: 3.10
12
11
  Classifier: Programming Language :: Python :: 3.11
13
12
  Classifier: Programming Language :: Python :: 3.12
14
13
  Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: 3.15
15
16
  Classifier: Programming Language :: Python :: Implementation :: CPython
16
17
  Classifier: Programming Language :: Python :: Implementation :: PyPy
17
18
  Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
@@ -24,6 +25,12 @@ Requires-Dist: pytest; extra == "dev"
24
25
  Requires-Dist: black; extra == "dev"
25
26
  Requires-Dist: pyflakes; extra == "dev"
26
27
  Requires-Dist: pytest-coverage; extra == "dev"
28
+ Requires-Dist: pytest-timeout>=2.4.0; extra == "dev"
29
+ Provides-Extra: docs
30
+ Requires-Dist: mkdocs; extra == "docs"
31
+ Requires-Dist: mkdocs-material; extra == "docs"
32
+ Requires-Dist: mkdocstrings[python]; extra == "docs"
33
+ Dynamic: license-file
27
34
 
28
35
  # Extracontext: Context Local Variables for everyone
29
36
 
@@ -0,0 +1,12 @@
1
+
2
+ [dev]
3
+ pytest
4
+ black
5
+ pyflakes
6
+ pytest-coverage
7
+ pytest-timeout>=2.4.0
8
+
9
+ [docs]
10
+ mkdocs
11
+ mkdocs-material
12
+ mkdocstrings[python]
@@ -9,7 +9,6 @@ from extracontext import ContextPreservingExecutor, ContextLocal
9
9
 
10
10
  def test_executor_preserves_context():
11
11
  # test executed using ordinary contexts
12
-
13
12
  executor = ContextPreservingExecutor(1)
14
13
 
15
14
  myvar = None
@@ -24,7 +23,6 @@ def test_executor_preserves_context():
24
23
 
25
24
  async def stage_2():
26
25
  nonlocal all_ok, message # myvar
27
-
28
26
  myvar.set(23)
29
27
  loop = asyncio.get_running_loop()
30
28
  task1 = loop.run_in_executor(executor, stage_3)
@@ -1,6 +0,0 @@
1
-
2
- [dev]
3
- pytest
4
- black
5
- pyflakes
6
- pytest-coverage