jasonfan commited on
Commit
71687cf
·
verified ·
1 Parent(s): 7475f0d

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/INSTALLER +1 -0
  2. miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/METADATA +93 -0
  3. miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/RECORD +92 -0
  4. miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/REQUESTED +0 -0
  5. miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/WHEEL +5 -0
  6. miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/direct_url.json +1 -0
  7. miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/entry_points.txt +2 -0
  8. miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/licenses/LICENSE +20 -0
  9. miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/top_level.txt +1 -0
  10. miniconda3/lib/python3.13/site-packages/anyio/_core/_contextmanagers.py +200 -0
  11. miniconda3/lib/python3.13/site-packages/anyio/_core/_eventloop.py +166 -0
  12. miniconda3/lib/python3.13/site-packages/anyio/_core/_exceptions.py +134 -0
  13. miniconda3/lib/python3.13/site-packages/anyio/_core/_fileio.py +740 -0
  14. miniconda3/lib/python3.13/site-packages/anyio/_core/_resources.py +18 -0
  15. miniconda3/lib/python3.13/site-packages/anyio/_core/_signals.py +27 -0
  16. miniconda3/lib/python3.13/site-packages/anyio/_core/_sockets.py +934 -0
  17. miniconda3/lib/python3.13/site-packages/anyio/_core/_streams.py +52 -0
  18. miniconda3/lib/python3.13/site-packages/anyio/_core/_subprocesses.py +202 -0
  19. miniconda3/lib/python3.13/site-packages/anyio/_core/_synchronization.py +732 -0
  20. miniconda3/lib/python3.13/site-packages/anyio/_core/_tasks.py +158 -0
  21. miniconda3/lib/python3.13/site-packages/anyio/_core/_tempfile.py +616 -0
  22. miniconda3/lib/python3.13/site-packages/anyio/_core/_testing.py +78 -0
  23. miniconda3/lib/python3.13/site-packages/anyio/_core/_typedattr.py +81 -0
  24. miniconda3/lib/python3.13/site-packages/anyio/abc/__init__.py +58 -0
  25. miniconda3/lib/python3.13/site-packages/anyio/abc/_eventloop.py +418 -0
  26. miniconda3/lib/python3.13/site-packages/anyio/abc/_resources.py +33 -0
  27. miniconda3/lib/python3.13/site-packages/anyio/abc/_sockets.py +405 -0
  28. miniconda3/lib/python3.13/site-packages/anyio/abc/_streams.py +239 -0
  29. miniconda3/lib/python3.13/site-packages/anyio/abc/_subprocesses.py +79 -0
  30. miniconda3/lib/python3.13/site-packages/anyio/abc/_tasks.py +112 -0
  31. miniconda3/lib/python3.13/site-packages/anyio/abc/_testing.py +65 -0
  32. miniconda3/lib/python3.13/site-packages/anyio/streams/__init__.py +0 -0
  33. miniconda3/lib/python3.13/site-packages/anyio/streams/buffered.py +182 -0
  34. miniconda3/lib/python3.13/site-packages/anyio/streams/file.py +148 -0
  35. miniconda3/lib/python3.13/site-packages/anyio/streams/memory.py +319 -0
  36. miniconda3/lib/python3.13/site-packages/anyio/streams/stapled.py +141 -0
  37. miniconda3/lib/python3.13/site-packages/anyio/streams/text.py +169 -0
  38. miniconda3/lib/python3.13/site-packages/anyio/streams/tls.py +417 -0
  39. miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/INSTALLER +1 -0
  40. miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/METADATA +123 -0
  41. miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/RECORD +88 -0
  42. miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/REQUESTED +0 -0
  43. miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/WHEEL +4 -0
  44. miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/direct_url.json +1 -0
  45. miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/entry_points.txt +3 -0
  46. miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/licenses/LICENSE-APACHE +202 -0
  47. miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/licenses/LICENSE-MIT +20 -0
  48. miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/licenses/NOTICE +21 -0
  49. miniconda3/lib/python3.13/site-packages/archspec/__init__.py +3 -0
  50. miniconda3/lib/python3.13/site-packages/archspec/__main__.py +9 -0
miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ conda
miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/METADATA ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: anyio
3
+ Version: 4.10.0
4
+ Summary: High-level concurrency and networking framework on top of asyncio or Trio
5
+ Author-email: Alex Grönholm <alex.gronholm@nextday.fi>
6
+ License-Expression: MIT
7
+ Project-URL: Documentation, https://anyio.readthedocs.io/en/latest/
8
+ Project-URL: Changelog, https://anyio.readthedocs.io/en/stable/versionhistory.html
9
+ Project-URL: Source code, https://github.com/agronholm/anyio
10
+ Project-URL: Issue tracker, https://github.com/agronholm/anyio/issues
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Framework :: AnyIO
14
+ Classifier: Typing :: Typed
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/x-rst
25
+ License-File: LICENSE
26
+ Requires-Dist: exceptiongroup>=1.0.2; python_version < "3.11"
27
+ Requires-Dist: idna>=2.8
28
+ Requires-Dist: sniffio>=1.1
29
+ Requires-Dist: typing_extensions>=4.5; python_version < "3.13"
30
+ Provides-Extra: trio
31
+ Requires-Dist: trio>=0.26.1; extra == "trio"
32
+ Dynamic: license-file
33
+
34
+ .. image:: https://github.com/agronholm/anyio/actions/workflows/test.yml/badge.svg
35
+ :target: https://github.com/agronholm/anyio/actions/workflows/test.yml
36
+ :alt: Build Status
37
+ .. image:: https://coveralls.io/repos/github/agronholm/anyio/badge.svg?branch=master
38
+ :target: https://coveralls.io/github/agronholm/anyio?branch=master
39
+ :alt: Code Coverage
40
+ .. image:: https://readthedocs.org/projects/anyio/badge/?version=latest
41
+ :target: https://anyio.readthedocs.io/en/latest/?badge=latest
42
+ :alt: Documentation
43
+ .. image:: https://badges.gitter.im/gitterHQ/gitter.svg
44
+ :target: https://gitter.im/python-trio/AnyIO
45
+ :alt: Gitter chat
46
+
47
+ AnyIO is an asynchronous networking and concurrency library that works on top of either asyncio_ or
48
+ Trio_. It implements Trio-like `structured concurrency`_ (SC) on top of asyncio and works in harmony
49
+ with the native SC of Trio itself.
50
+
51
+ Applications and libraries written against AnyIO's API will run unmodified on either asyncio_ or
52
+ Trio_. AnyIO can also be adopted into a library or application incrementally – bit by bit, no full
53
+ refactoring necessary. It will blend in with the native libraries of your chosen backend.
54
+
55
+ To find out why you might want to use AnyIO's APIs instead of asyncio's, you can read about it
56
+ `here <https://anyio.readthedocs.io/en/stable/why.html>`_.
57
+
58
+ Documentation
59
+ -------------
60
+
61
+ View full documentation at: https://anyio.readthedocs.io/
62
+
63
+ Features
64
+ --------
65
+
66
+ AnyIO offers the following functionality:
67
+
68
+ * Task groups (nurseries_ in trio terminology)
69
+ * High-level networking (TCP, UDP and UNIX sockets)
70
+
71
+ * `Happy eyeballs`_ algorithm for TCP connections (more robust than that of asyncio on Python
72
+ 3.8)
73
+ * async/await style UDP sockets (unlike asyncio where you still have to use Transports and
74
+ Protocols)
75
+
76
+ * A versatile API for byte streams and object streams
77
+ * Inter-task synchronization and communication (locks, conditions, events, semaphores, object
78
+ streams)
79
+ * Worker threads
80
+ * Subprocesses
81
+ * Asynchronous file I/O (using worker threads)
82
+ * Signal handling
83
+
84
+ AnyIO also comes with its own pytest_ plugin which also supports asynchronous fixtures.
85
+ It even works with the popular Hypothesis_ library.
86
+
87
+ .. _asyncio: https://docs.python.org/3/library/asyncio.html
88
+ .. _Trio: https://github.com/python-trio/trio
89
+ .. _structured concurrency: https://en.wikipedia.org/wiki/Structured_concurrency
90
+ .. _nurseries: https://trio.readthedocs.io/en/stable/reference-core.html#nurseries-and-spawning
91
+ .. _Happy eyeballs: https://en.wikipedia.org/wiki/Happy_Eyeballs
92
+ .. _pytest: https://docs.pytest.org/en/latest/
93
+ .. _Hypothesis: https://hypothesis.works/
miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/RECORD ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ anyio-4.10.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ anyio-4.10.0.dist-info/METADATA,sha256=1AD_60gPgqxWKsO54FUTbKDQHyni5j_56_XQinKJ9LQ,4014
3
+ anyio-4.10.0.dist-info/RECORD,,
4
+ anyio-4.10.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ anyio-4.10.0.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
6
+ anyio-4.10.0.dist-info/direct_url.json,sha256=_djiGnNnx3NQOth1G4F9V3DODy6L0cLvQ2kejcS-UZ8,95
7
+ anyio-4.10.0.dist-info/entry_points.txt,sha256=_d6Yu6uiaZmNe0CydowirE9Cmg7zUL2g08tQpoS3Qvc,39
8
+ anyio-4.10.0.dist-info/licenses/LICENSE,sha256=U2GsncWPLvX9LpsJxoKXwX8ElQkJu8gCO9uC6s8iwrA,1081
9
+ anyio-4.10.0.dist-info/top_level.txt,sha256=QglSMiWX8_5dpoVAEIHdEYzvqFMdSYWmCj6tYw2ITkQ,6
10
+ anyio/__init__.py,sha256=z3IyWgWQuxCi-KUwma-1LSys4WB50mV2N8FvS9_IePE,5955
11
+ anyio/__pycache__/__init__.cpython-313.pyc,,
12
+ anyio/__pycache__/from_thread.cpython-313.pyc,,
13
+ anyio/__pycache__/lowlevel.cpython-313.pyc,,
14
+ anyio/__pycache__/pytest_plugin.cpython-313.pyc,,
15
+ anyio/__pycache__/to_interpreter.cpython-313.pyc,,
16
+ anyio/__pycache__/to_process.cpython-313.pyc,,
17
+ anyio/__pycache__/to_thread.cpython-313.pyc,,
18
+ anyio/_backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ anyio/_backends/__pycache__/__init__.cpython-313.pyc,,
20
+ anyio/_backends/__pycache__/_asyncio.cpython-313.pyc,,
21
+ anyio/_backends/__pycache__/_trio.cpython-313.pyc,,
22
+ anyio/_backends/_asyncio.py,sha256=YXpQJ0C-tNiYvZdElVa3zGflG_Jdvf7FNDiG9-THhMg,97359
23
+ anyio/_backends/_trio.py,sha256=tRGDtos6xmqmGlstfI8wEjGvhZq0y_SYTaM2m8zatRU,41963
24
+ anyio/_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
+ anyio/_core/__pycache__/__init__.cpython-313.pyc,,
26
+ anyio/_core/__pycache__/_asyncio_selector_thread.cpython-313.pyc,,
27
+ anyio/_core/__pycache__/_contextmanagers.cpython-313.pyc,,
28
+ anyio/_core/__pycache__/_eventloop.cpython-313.pyc,,
29
+ anyio/_core/__pycache__/_exceptions.cpython-313.pyc,,
30
+ anyio/_core/__pycache__/_fileio.cpython-313.pyc,,
31
+ anyio/_core/__pycache__/_resources.cpython-313.pyc,,
32
+ anyio/_core/__pycache__/_signals.cpython-313.pyc,,
33
+ anyio/_core/__pycache__/_sockets.cpython-313.pyc,,
34
+ anyio/_core/__pycache__/_streams.cpython-313.pyc,,
35
+ anyio/_core/__pycache__/_subprocesses.cpython-313.pyc,,
36
+ anyio/_core/__pycache__/_synchronization.cpython-313.pyc,,
37
+ anyio/_core/__pycache__/_tasks.cpython-313.pyc,,
38
+ anyio/_core/__pycache__/_tempfile.cpython-313.pyc,,
39
+ anyio/_core/__pycache__/_testing.cpython-313.pyc,,
40
+ anyio/_core/__pycache__/_typedattr.cpython-313.pyc,,
41
+ anyio/_core/_asyncio_selector_thread.py,sha256=2PdxFM3cs02Kp6BSppbvmRT7q7asreTW5FgBxEsflBo,5626
42
+ anyio/_core/_contextmanagers.py,sha256=YInBCabiEeS-UaP_Jdxa1CaFC71ETPW8HZTHIM8Rsc8,7215
43
+ anyio/_core/_eventloop.py,sha256=t_tAwBFPjF8jrZGjlJ6bbYy6KA3bjsbZxV9mvh9t1i0,4695
44
+ anyio/_core/_exceptions.py,sha256=uQ9yXs3gRghZiuxiWtbvVlHB6CvCRtxObKMWF-Mnz18,3683
45
+ anyio/_core/_fileio.py,sha256=KATysDZP7bvwwjpUwEaGAc0xGouJgAPqNVpnBMTsToY,23332
46
+ anyio/_core/_resources.py,sha256=NbmU5O5UX3xEyACnkmYX28Fmwdl-f-ny0tHym26e0w0,435
47
+ anyio/_core/_signals.py,sha256=vulT1M1xdLYtAR-eY5TamIgaf1WTlOwOrMGwswlTTr8,905
48
+ anyio/_core/_sockets.py,sha256=MRo3vVzBLnWwA0DqjWhJ2ICj_XKQ78BtWxdrSAwKcxU,32232
49
+ anyio/_core/_streams.py,sha256=OnaKgoDD-FcMSwLvkoAUGP51sG2ZdRvMpxt9q2w1gYA,1804
50
+ anyio/_core/_subprocesses.py,sha256=EXm5igL7dj55iYkPlbYVAqtbqxJxjU-6OndSTIx9SRg,8047
51
+ anyio/_core/_synchronization.py,sha256=76KyUbGD3A3eCXPrLnOccQfRsNSxIcoR36JeK1P4VFQ,20306
52
+ anyio/_core/_tasks.py,sha256=f3CuWwo06cCZ6jaOv-JHFKWkgpgf2cvaF25Oh4augMA,4757
53
+ anyio/_core/_tempfile.py,sha256=lHb7CW4FyIlpkf5ADAf4VmLHCKwEHF9nxqNyBCFFUiA,19697
54
+ anyio/_core/_testing.py,sha256=YUGwA5cgFFbUTv4WFd7cv_BSVr4ryTtPp8owQA3JdWE,2118
55
+ anyio/_core/_typedattr.py,sha256=P4ozZikn3-DbpoYcvyghS_FOYAgbmUxeoU8-L_07pZM,2508
56
+ anyio/abc/__init__.py,sha256=6mWhcl_pGXhrgZVHP_TCfMvIXIOp9mroEFM90fYCU_U,2869
57
+ anyio/abc/__pycache__/__init__.cpython-313.pyc,,
58
+ anyio/abc/__pycache__/_eventloop.cpython-313.pyc,,
59
+ anyio/abc/__pycache__/_resources.cpython-313.pyc,,
60
+ anyio/abc/__pycache__/_sockets.cpython-313.pyc,,
61
+ anyio/abc/__pycache__/_streams.cpython-313.pyc,,
62
+ anyio/abc/__pycache__/_subprocesses.cpython-313.pyc,,
63
+ anyio/abc/__pycache__/_tasks.cpython-313.pyc,,
64
+ anyio/abc/__pycache__/_testing.cpython-313.pyc,,
65
+ anyio/abc/_eventloop.py,sha256=_rrVDoNAS9yIFvSE70ewoppYd_9zNbRjPFl5UPMSR8I,10729
66
+ anyio/abc/_resources.py,sha256=DrYvkNN1hH6Uvv5_5uKySvDsnknGVDe8FCKfko0VtN8,783
67
+ anyio/abc/_sockets.py,sha256=ECTY0jLEF18gryANHR3vFzXzGdZ-xPwELq1QdgOb0Jo,13258
68
+ anyio/abc/_streams.py,sha256=005GKSCXGprxnhucILboSqc2JFovECZk9m3p-qqxXVc,7640
69
+ anyio/abc/_subprocesses.py,sha256=cumAPJTktOQtw63IqG0lDpyZqu_l1EElvQHMiwJgL08,2067
70
+ anyio/abc/_tasks.py,sha256=Jh4LXVz1DoRacOnw1rwAS9wujNiEWK9oqdF0cTEhhNA,3604
71
+ anyio/abc/_testing.py,sha256=tBJUzkSfOXJw23fe8qSJ03kJlShOYjjaEyFB6k6MYT8,1821
72
+ anyio/from_thread.py,sha256=t8B_amqFBqlJy8X18mhvpYkhzeSXmRsI-ep6Yg04H4M,17678
73
+ anyio/lowlevel.py,sha256=IisVkje5kwqOCpe-RgBjGCvlr-JBFGBrkobR7iZ3Fv4,4153
74
+ anyio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
75
+ anyio/pytest_plugin.py,sha256=qXNwk9Pa7hPQKWocgLl9qijqKGMkGzdH2wJa-jPkGUM,9375
76
+ anyio/streams/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
77
+ anyio/streams/__pycache__/__init__.cpython-313.pyc,,
78
+ anyio/streams/__pycache__/buffered.cpython-313.pyc,,
79
+ anyio/streams/__pycache__/file.cpython-313.pyc,,
80
+ anyio/streams/__pycache__/memory.cpython-313.pyc,,
81
+ anyio/streams/__pycache__/stapled.cpython-313.pyc,,
82
+ anyio/streams/__pycache__/text.cpython-313.pyc,,
83
+ anyio/streams/__pycache__/tls.cpython-313.pyc,,
84
+ anyio/streams/buffered.py,sha256=joUPdz0OoRfKgGmMpHI9vZyMNm6ly9iFlofrZUPs9cQ,6162
85
+ anyio/streams/file.py,sha256=6uoTNb5KbMoj-6gS3_xrrL8uZN8Q4iIvOS1WtGyFfKw,4383
86
+ anyio/streams/memory.py,sha256=GcbF3cahdsdFZtcTZaIKpZXPDZKogj18wWPPmE0OmGU,10620
87
+ anyio/streams/stapled.py,sha256=U09pCrmOw9kkNhe6tKopsm1QIMT1lFTFvtb-A7SIe4k,4302
88
+ anyio/streams/text.py,sha256=tCJ8ljavGM-HY0aL-5Twxv-Kyw1BfR0B4OtVIB6kZ9w,5662
89
+ anyio/streams/tls.py,sha256=siSaaRyX-XnfC7Jbn9VjtIdVzJkDsvIW_2pSEVheDFQ,15275
90
+ anyio/to_interpreter.py,sha256=Z0-kLCxlITjFG_RM_TNdUlEnog94l48GXVDZ80w0URc,6986
91
+ anyio/to_process.py,sha256=ZvruelRM-HNmqDaql4sdNODg2QD_uSlwSCxnV4OhsfQ,9595
92
+ anyio/to_thread.py,sha256=WM2JQ2MbVsd5D5CM08bQiTwzZIvpsGjfH1Fy247KoDQ,2396
miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/REQUESTED ADDED
File without changes
miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (78.1.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/direct_url.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"dir_info": {}, "url": "file:///home/task_175862240717140/conda-bld/anyio_1758622421932/work"}
miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/entry_points.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [pytest11]
2
+ anyio = anyio.pytest_plugin
miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/licenses/LICENSE ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Alex Grönholm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
miniconda3/lib/python3.13/site-packages/anyio-4.10.0.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ anyio
miniconda3/lib/python3.13/site-packages/anyio/_core/_contextmanagers.py ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from abc import abstractmethod
4
+ from contextlib import AbstractAsyncContextManager, AbstractContextManager
5
+ from inspect import isasyncgen, iscoroutine, isgenerator
6
+ from types import TracebackType
7
+ from typing import Protocol, TypeVar, cast, final
8
+
9
+ _T_co = TypeVar("_T_co", covariant=True)
10
+ _ExitT_co = TypeVar("_ExitT_co", covariant=True, bound="bool | None")
11
+
12
+
13
+ class _SupportsCtxMgr(Protocol[_T_co, _ExitT_co]):
14
+ def __contextmanager__(self) -> AbstractContextManager[_T_co, _ExitT_co]: ...
15
+
16
+
17
+ class _SupportsAsyncCtxMgr(Protocol[_T_co, _ExitT_co]):
18
+ def __asynccontextmanager__(
19
+ self,
20
+ ) -> AbstractAsyncContextManager[_T_co, _ExitT_co]: ...
21
+
22
+
23
+ class ContextManagerMixin:
24
+ """
25
+ Mixin class providing context manager functionality via a generator-based
26
+ implementation.
27
+
28
+ This class allows you to implement a context manager via :meth:`__contextmanager__`
29
+ which should return a generator. The mechanics are meant to mirror those of
30
+ :func:`@contextmanager <contextlib.contextmanager>`.
31
+
32
+ .. note:: Classes using this mix-in are not reentrant as context managers, meaning
33
+ that once you enter it, you can't re-enter before first exiting it.
34
+
35
+ .. seealso:: :doc:`contextmanagers`
36
+ """
37
+
38
+ __cm: AbstractContextManager[object, bool | None] | None = None
39
+
40
+ @final
41
+ def __enter__(self: _SupportsCtxMgr[_T_co, bool | None]) -> _T_co:
42
+ # Needed for mypy to assume self still has the __cm member
43
+ assert isinstance(self, ContextManagerMixin)
44
+ if self.__cm is not None:
45
+ raise RuntimeError(
46
+ f"this {self.__class__.__qualname__} has already been entered"
47
+ )
48
+
49
+ cm = self.__contextmanager__()
50
+ if not isinstance(cm, AbstractContextManager):
51
+ if isgenerator(cm):
52
+ raise TypeError(
53
+ "__contextmanager__() returned a generator object instead of "
54
+ "a context manager. Did you forget to add the @contextmanager "
55
+ "decorator?"
56
+ )
57
+
58
+ raise TypeError(
59
+ f"__contextmanager__() did not return a context manager object, "
60
+ f"but {cm.__class__!r}"
61
+ )
62
+
63
+ if cm is self:
64
+ raise TypeError(
65
+ f"{self.__class__.__qualname__}.__contextmanager__() returned "
66
+ f"self. Did you forget to add the @contextmanager decorator and a "
67
+ f"'yield' statement?"
68
+ )
69
+
70
+ value = cm.__enter__()
71
+ self.__cm = cm
72
+ return value
73
+
74
+ @final
75
+ def __exit__(
76
+ self: _SupportsCtxMgr[object, _ExitT_co],
77
+ exc_type: type[BaseException] | None,
78
+ exc_val: BaseException | None,
79
+ exc_tb: TracebackType | None,
80
+ ) -> _ExitT_co:
81
+ # Needed for mypy to assume self still has the __cm member
82
+ assert isinstance(self, ContextManagerMixin)
83
+ if self.__cm is None:
84
+ raise RuntimeError(
85
+ f"this {self.__class__.__qualname__} has not been entered yet"
86
+ )
87
+
88
+ # Prevent circular references
89
+ cm = self.__cm
90
+ del self.__cm
91
+
92
+ return cast(_ExitT_co, cm.__exit__(exc_type, exc_val, exc_tb))
93
+
94
+ @abstractmethod
95
+ def __contextmanager__(self) -> AbstractContextManager[object, bool | None]:
96
+ """
97
+ Implement your context manager logic here.
98
+
99
+ This method **must** be decorated with
100
+ :func:`@contextmanager <contextlib.contextmanager>`.
101
+
102
+ .. note:: Remember that the ``yield`` will raise any exception raised in the
103
+ enclosed context block, so use a ``finally:`` block to clean up resources!
104
+
105
+ :return: a context manager object
106
+ """
107
+
108
+
109
+ class AsyncContextManagerMixin:
110
+ """
111
+ Mixin class providing async context manager functionality via a generator-based
112
+ implementation.
113
+
114
+ This class allows you to implement a context manager via
115
+ :meth:`__asynccontextmanager__`. The mechanics are meant to mirror those of
116
+ :func:`@asynccontextmanager <contextlib.asynccontextmanager>`.
117
+
118
+ .. note:: Classes using this mix-in are not reentrant as context managers, meaning
119
+ that once you enter it, you can't re-enter before first exiting it.
120
+
121
+ .. seealso:: :doc:`contextmanagers`
122
+ """
123
+
124
+ __cm: AbstractAsyncContextManager[object, bool | None] | None = None
125
+
126
+ @final
127
+ async def __aenter__(self: _SupportsAsyncCtxMgr[_T_co, bool | None]) -> _T_co:
128
+ # Needed for mypy to assume self still has the __cm member
129
+ assert isinstance(self, AsyncContextManagerMixin)
130
+ if self.__cm is not None:
131
+ raise RuntimeError(
132
+ f"this {self.__class__.__qualname__} has already been entered"
133
+ )
134
+
135
+ cm = self.__asynccontextmanager__()
136
+ if not isinstance(cm, AbstractAsyncContextManager):
137
+ if isasyncgen(cm):
138
+ raise TypeError(
139
+ "__asynccontextmanager__() returned an async generator instead of "
140
+ "an async context manager. Did you forget to add the "
141
+ "@asynccontextmanager decorator?"
142
+ )
143
+ elif iscoroutine(cm):
144
+ cm.close()
145
+ raise TypeError(
146
+ "__asynccontextmanager__() returned a coroutine object instead of "
147
+ "an async context manager. Did you forget to add the "
148
+ "@asynccontextmanager decorator and a 'yield' statement?"
149
+ )
150
+
151
+ raise TypeError(
152
+ f"__asynccontextmanager__() did not return an async context manager, "
153
+ f"but {cm.__class__!r}"
154
+ )
155
+
156
+ if cm is self:
157
+ raise TypeError(
158
+ f"{self.__class__.__qualname__}.__asynccontextmanager__() returned "
159
+ f"self. Did you forget to add the @asynccontextmanager decorator and a "
160
+ f"'yield' statement?"
161
+ )
162
+
163
+ value = await cm.__aenter__()
164
+ self.__cm = cm
165
+ return value
166
+
167
+ @final
168
+ async def __aexit__(
169
+ self: _SupportsAsyncCtxMgr[object, _ExitT_co],
170
+ exc_type: type[BaseException] | None,
171
+ exc_val: BaseException | None,
172
+ exc_tb: TracebackType | None,
173
+ ) -> _ExitT_co:
174
+ assert isinstance(self, AsyncContextManagerMixin)
175
+ if self.__cm is None:
176
+ raise RuntimeError(
177
+ f"this {self.__class__.__qualname__} has not been entered yet"
178
+ )
179
+
180
+ # Prevent circular references
181
+ cm = self.__cm
182
+ del self.__cm
183
+
184
+ return cast(_ExitT_co, await cm.__aexit__(exc_type, exc_val, exc_tb))
185
+
186
+ @abstractmethod
187
+ def __asynccontextmanager__(
188
+ self,
189
+ ) -> AbstractAsyncContextManager[object, bool | None]:
190
+ """
191
+ Implement your async context manager logic here.
192
+
193
+ This method **must** be decorated with
194
+ :func:`@asynccontextmanager <contextlib.asynccontextmanager>`.
195
+
196
+ .. note:: Remember that the ``yield`` will raise any exception raised in the
197
+ enclosed context block, so use a ``finally:`` block to clean up resources!
198
+
199
+ :return: an async context manager object
200
+ """
miniconda3/lib/python3.13/site-packages/anyio/_core/_eventloop.py ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import math
4
+ import sys
5
+ import threading
6
+ from collections.abc import Awaitable, Callable, Generator
7
+ from contextlib import contextmanager
8
+ from importlib import import_module
9
+ from typing import TYPE_CHECKING, Any, TypeVar
10
+
11
+ import sniffio
12
+
13
+ if sys.version_info >= (3, 11):
14
+ from typing import TypeVarTuple, Unpack
15
+ else:
16
+ from typing_extensions import TypeVarTuple, Unpack
17
+
18
+ if TYPE_CHECKING:
19
+ from ..abc import AsyncBackend
20
+
21
+ # This must be updated when new backends are introduced
22
+ BACKENDS = "asyncio", "trio"
23
+
24
+ T_Retval = TypeVar("T_Retval")
25
+ PosArgsT = TypeVarTuple("PosArgsT")
26
+
27
+ threadlocals = threading.local()
28
+ loaded_backends: dict[str, type[AsyncBackend]] = {}
29
+
30
+
31
+ def run(
32
+ func: Callable[[Unpack[PosArgsT]], Awaitable[T_Retval]],
33
+ *args: Unpack[PosArgsT],
34
+ backend: str = "asyncio",
35
+ backend_options: dict[str, Any] | None = None,
36
+ ) -> T_Retval:
37
+ """
38
+ Run the given coroutine function in an asynchronous event loop.
39
+
40
+ The current thread must not be already running an event loop.
41
+
42
+ :param func: a coroutine function
43
+ :param args: positional arguments to ``func``
44
+ :param backend: name of the asynchronous event loop implementation – currently
45
+ either ``asyncio`` or ``trio``
46
+ :param backend_options: keyword arguments to call the backend ``run()``
47
+ implementation with (documented :ref:`here <backend options>`)
48
+ :return: the return value of the coroutine function
49
+ :raises RuntimeError: if an asynchronous event loop is already running in this
50
+ thread
51
+ :raises LookupError: if the named backend is not found
52
+
53
+ """
54
+ try:
55
+ asynclib_name = sniffio.current_async_library()
56
+ except sniffio.AsyncLibraryNotFoundError:
57
+ pass
58
+ else:
59
+ raise RuntimeError(f"Already running {asynclib_name} in this thread")
60
+
61
+ try:
62
+ async_backend = get_async_backend(backend)
63
+ except ImportError as exc:
64
+ raise LookupError(f"No such backend: {backend}") from exc
65
+
66
+ token = None
67
+ if sniffio.current_async_library_cvar.get(None) is None:
68
+ # Since we're in control of the event loop, we can cache the name of the async
69
+ # library
70
+ token = sniffio.current_async_library_cvar.set(backend)
71
+
72
+ try:
73
+ backend_options = backend_options or {}
74
+ return async_backend.run(func, args, {}, backend_options)
75
+ finally:
76
+ if token:
77
+ sniffio.current_async_library_cvar.reset(token)
78
+
79
+
80
+ async def sleep(delay: float) -> None:
81
+ """
82
+ Pause the current task for the specified duration.
83
+
84
+ :param delay: the duration, in seconds
85
+
86
+ """
87
+ return await get_async_backend().sleep(delay)
88
+
89
+
90
+ async def sleep_forever() -> None:
91
+ """
92
+ Pause the current task until it's cancelled.
93
+
94
+ This is a shortcut for ``sleep(math.inf)``.
95
+
96
+ .. versionadded:: 3.1
97
+
98
+ """
99
+ await sleep(math.inf)
100
+
101
+
102
+ async def sleep_until(deadline: float) -> None:
103
+ """
104
+ Pause the current task until the given time.
105
+
106
+ :param deadline: the absolute time to wake up at (according to the internal
107
+ monotonic clock of the event loop)
108
+
109
+ .. versionadded:: 3.1
110
+
111
+ """
112
+ now = current_time()
113
+ await sleep(max(deadline - now, 0))
114
+
115
+
116
+ def current_time() -> float:
117
+ """
118
+ Return the current value of the event loop's internal clock.
119
+
120
+ :return: the clock value (seconds)
121
+
122
+ """
123
+ return get_async_backend().current_time()
124
+
125
+
126
+ def get_all_backends() -> tuple[str, ...]:
127
+ """Return a tuple of the names of all built-in backends."""
128
+ return BACKENDS
129
+
130
+
131
+ def get_cancelled_exc_class() -> type[BaseException]:
132
+ """Return the current async library's cancellation exception class."""
133
+ return get_async_backend().cancelled_exception_class()
134
+
135
+
136
+ #
137
+ # Private API
138
+ #
139
+
140
+
141
+ @contextmanager
142
+ def claim_worker_thread(
143
+ backend_class: type[AsyncBackend], token: object
144
+ ) -> Generator[Any, None, None]:
145
+ threadlocals.current_async_backend = backend_class
146
+ threadlocals.current_token = token
147
+ try:
148
+ yield
149
+ finally:
150
+ del threadlocals.current_async_backend
151
+ del threadlocals.current_token
152
+
153
+
154
+ def get_async_backend(asynclib_name: str | None = None) -> type[AsyncBackend]:
155
+ if asynclib_name is None:
156
+ asynclib_name = sniffio.current_async_library()
157
+
158
+ # We use our own dict instead of sys.modules to get the already imported back-end
159
+ # class because the appropriate modules in sys.modules could potentially be only
160
+ # partially initialized
161
+ try:
162
+ return loaded_backends[asynclib_name]
163
+ except KeyError:
164
+ module = import_module(f"anyio._backends._{asynclib_name}")
165
+ loaded_backends[asynclib_name] = module.backend_class
166
+ return module.backend_class
miniconda3/lib/python3.13/site-packages/anyio/_core/_exceptions.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ from collections.abc import Generator
5
+ from textwrap import dedent
6
+ from typing import Any
7
+
8
+ if sys.version_info < (3, 11):
9
+ from exceptiongroup import BaseExceptionGroup
10
+
11
+
12
+ class BrokenResourceError(Exception):
13
+ """
14
+ Raised when trying to use a resource that has been rendered unusable due to external
15
+ causes (e.g. a send stream whose peer has disconnected).
16
+ """
17
+
18
+
19
+ class BrokenWorkerProcess(Exception):
20
+ """
21
+ Raised by :meth:`~anyio.to_process.run_sync` if the worker process terminates abruptly or
22
+ otherwise misbehaves.
23
+ """
24
+
25
+
26
+ class BrokenWorkerInterpreter(Exception):
27
+ """
28
+ Raised by :meth:`~anyio.to_interpreter.run_sync` if an unexpected exception is
29
+ raised in the subinterpreter.
30
+ """
31
+
32
+ def __init__(self, excinfo: Any):
33
+ # This was adapted from concurrent.futures.interpreter.ExecutionFailed
34
+ msg = excinfo.formatted
35
+ if not msg:
36
+ if excinfo.type and excinfo.msg:
37
+ msg = f"{excinfo.type.__name__}: {excinfo.msg}"
38
+ else:
39
+ msg = excinfo.type.__name__ or excinfo.msg
40
+
41
+ super().__init__(msg)
42
+ self.excinfo = excinfo
43
+
44
+ def __str__(self) -> str:
45
+ try:
46
+ formatted = self.excinfo.errdisplay
47
+ except Exception:
48
+ return super().__str__()
49
+ else:
50
+ return dedent(
51
+ f"""
52
+ {super().__str__()}
53
+
54
+ Uncaught in the interpreter:
55
+
56
+ {formatted}
57
+ """.strip()
58
+ )
59
+
60
+
61
+ class BusyResourceError(Exception):
62
+ """
63
+ Raised when two tasks are trying to read from or write to the same resource
64
+ concurrently.
65
+ """
66
+
67
+ def __init__(self, action: str):
68
+ super().__init__(f"Another task is already {action} this resource")
69
+
70
+
71
+ class ClosedResourceError(Exception):
72
+ """Raised when trying to use a resource that has been closed."""
73
+
74
+
75
+ class ConnectionFailed(OSError):
76
+ """
77
+ Raised when a connection attempt fails.
78
+
79
+ .. note:: This class inherits from :exc:`OSError` for backwards compatibility.
80
+ """
81
+
82
+
83
+ def iterate_exceptions(
84
+ exception: BaseException,
85
+ ) -> Generator[BaseException, None, None]:
86
+ if isinstance(exception, BaseExceptionGroup):
87
+ for exc in exception.exceptions:
88
+ yield from iterate_exceptions(exc)
89
+ else:
90
+ yield exception
91
+
92
+
93
+ class DelimiterNotFound(Exception):
94
+ """
95
+ Raised during
96
+ :meth:`~anyio.streams.buffered.BufferedByteReceiveStream.receive_until` if the
97
+ maximum number of bytes has been read without the delimiter being found.
98
+ """
99
+
100
+ def __init__(self, max_bytes: int) -> None:
101
+ super().__init__(
102
+ f"The delimiter was not found among the first {max_bytes} bytes"
103
+ )
104
+
105
+
106
+ class EndOfStream(Exception):
107
+ """
108
+ Raised when trying to read from a stream that has been closed from the other end.
109
+ """
110
+
111
+
112
+ class IncompleteRead(Exception):
113
+ """
114
+ Raised during
115
+ :meth:`~anyio.streams.buffered.BufferedByteReceiveStream.receive_exactly` or
116
+ :meth:`~anyio.streams.buffered.BufferedByteReceiveStream.receive_until` if the
117
+ connection is closed before the requested amount of bytes has been read.
118
+ """
119
+
120
+ def __init__(self) -> None:
121
+ super().__init__(
122
+ "The stream was closed before the read operation could be completed"
123
+ )
124
+
125
+
126
+ class TypedAttributeLookupError(LookupError):
127
+ """
128
+ Raised by :meth:`~anyio.TypedAttributeProvider.extra` when the given typed attribute
129
+ is not found and no default value has been given.
130
+ """
131
+
132
+
133
+ class WouldBlock(Exception):
134
+ """Raised by ``X_nowait`` functions if ``X()`` would block."""
miniconda3/lib/python3.13/site-packages/anyio/_core/_fileio.py ADDED
@@ -0,0 +1,740 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import pathlib
5
+ import sys
6
+ from collections.abc import (
7
+ AsyncIterator,
8
+ Callable,
9
+ Iterable,
10
+ Iterator,
11
+ Sequence,
12
+ )
13
+ from dataclasses import dataclass
14
+ from functools import partial
15
+ from os import PathLike
16
+ from typing import (
17
+ IO,
18
+ TYPE_CHECKING,
19
+ Any,
20
+ AnyStr,
21
+ ClassVar,
22
+ Final,
23
+ Generic,
24
+ overload,
25
+ )
26
+
27
+ from .. import to_thread
28
+ from ..abc import AsyncResource
29
+
30
+ if TYPE_CHECKING:
31
+ from types import ModuleType
32
+
33
+ from _typeshed import OpenBinaryMode, OpenTextMode, ReadableBuffer, WriteableBuffer
34
+ else:
35
+ ReadableBuffer = OpenBinaryMode = OpenTextMode = WriteableBuffer = object
36
+
37
+
38
+ class AsyncFile(AsyncResource, Generic[AnyStr]):
39
+ """
40
+ An asynchronous file object.
41
+
42
+ This class wraps a standard file object and provides async friendly versions of the
43
+ following blocking methods (where available on the original file object):
44
+
45
+ * read
46
+ * read1
47
+ * readline
48
+ * readlines
49
+ * readinto
50
+ * readinto1
51
+ * write
52
+ * writelines
53
+ * truncate
54
+ * seek
55
+ * tell
56
+ * flush
57
+
58
+ All other methods are directly passed through.
59
+
60
+ This class supports the asynchronous context manager protocol which closes the
61
+ underlying file at the end of the context block.
62
+
63
+ This class also supports asynchronous iteration::
64
+
65
+ async with await open_file(...) as f:
66
+ async for line in f:
67
+ print(line)
68
+ """
69
+
70
+ def __init__(self, fp: IO[AnyStr]) -> None:
71
+ self._fp: Any = fp
72
+
73
+ def __getattr__(self, name: str) -> object:
74
+ return getattr(self._fp, name)
75
+
76
+ @property
77
+ def wrapped(self) -> IO[AnyStr]:
78
+ """The wrapped file object."""
79
+ return self._fp
80
+
81
+ async def __aiter__(self) -> AsyncIterator[AnyStr]:
82
+ while True:
83
+ line = await self.readline()
84
+ if line:
85
+ yield line
86
+ else:
87
+ break
88
+
89
+ async def aclose(self) -> None:
90
+ return await to_thread.run_sync(self._fp.close)
91
+
92
+ async def read(self, size: int = -1) -> AnyStr:
93
+ return await to_thread.run_sync(self._fp.read, size)
94
+
95
+ async def read1(self: AsyncFile[bytes], size: int = -1) -> bytes:
96
+ return await to_thread.run_sync(self._fp.read1, size)
97
+
98
+ async def readline(self) -> AnyStr:
99
+ return await to_thread.run_sync(self._fp.readline)
100
+
101
+ async def readlines(self) -> list[AnyStr]:
102
+ return await to_thread.run_sync(self._fp.readlines)
103
+
104
+ async def readinto(self: AsyncFile[bytes], b: WriteableBuffer) -> int:
105
+ return await to_thread.run_sync(self._fp.readinto, b)
106
+
107
+ async def readinto1(self: AsyncFile[bytes], b: WriteableBuffer) -> int:
108
+ return await to_thread.run_sync(self._fp.readinto1, b)
109
+
110
+ @overload
111
+ async def write(self: AsyncFile[bytes], b: ReadableBuffer) -> int: ...
112
+
113
+ @overload
114
+ async def write(self: AsyncFile[str], b: str) -> int: ...
115
+
116
+ async def write(self, b: ReadableBuffer | str) -> int:
117
+ return await to_thread.run_sync(self._fp.write, b)
118
+
119
+ @overload
120
+ async def writelines(
121
+ self: AsyncFile[bytes], lines: Iterable[ReadableBuffer]
122
+ ) -> None: ...
123
+
124
+ @overload
125
+ async def writelines(self: AsyncFile[str], lines: Iterable[str]) -> None: ...
126
+
127
+ async def writelines(self, lines: Iterable[ReadableBuffer] | Iterable[str]) -> None:
128
+ return await to_thread.run_sync(self._fp.writelines, lines)
129
+
130
+ async def truncate(self, size: int | None = None) -> int:
131
+ return await to_thread.run_sync(self._fp.truncate, size)
132
+
133
+ async def seek(self, offset: int, whence: int | None = os.SEEK_SET) -> int:
134
+ return await to_thread.run_sync(self._fp.seek, offset, whence)
135
+
136
+ async def tell(self) -> int:
137
+ return await to_thread.run_sync(self._fp.tell)
138
+
139
+ async def flush(self) -> None:
140
+ return await to_thread.run_sync(self._fp.flush)
141
+
142
+
143
+ @overload
144
+ async def open_file(
145
+ file: str | PathLike[str] | int,
146
+ mode: OpenBinaryMode,
147
+ buffering: int = ...,
148
+ encoding: str | None = ...,
149
+ errors: str | None = ...,
150
+ newline: str | None = ...,
151
+ closefd: bool = ...,
152
+ opener: Callable[[str, int], int] | None = ...,
153
+ ) -> AsyncFile[bytes]: ...
154
+
155
+
156
+ @overload
157
+ async def open_file(
158
+ file: str | PathLike[str] | int,
159
+ mode: OpenTextMode = ...,
160
+ buffering: int = ...,
161
+ encoding: str | None = ...,
162
+ errors: str | None = ...,
163
+ newline: str | None = ...,
164
+ closefd: bool = ...,
165
+ opener: Callable[[str, int], int] | None = ...,
166
+ ) -> AsyncFile[str]: ...
167
+
168
+
169
+ async def open_file(
170
+ file: str | PathLike[str] | int,
171
+ mode: str = "r",
172
+ buffering: int = -1,
173
+ encoding: str | None = None,
174
+ errors: str | None = None,
175
+ newline: str | None = None,
176
+ closefd: bool = True,
177
+ opener: Callable[[str, int], int] | None = None,
178
+ ) -> AsyncFile[Any]:
179
+ """
180
+ Open a file asynchronously.
181
+
182
+ The arguments are exactly the same as for the builtin :func:`open`.
183
+
184
+ :return: an asynchronous file object
185
+
186
+ """
187
+ fp = await to_thread.run_sync(
188
+ open, file, mode, buffering, encoding, errors, newline, closefd, opener
189
+ )
190
+ return AsyncFile(fp)
191
+
192
+
193
+ def wrap_file(file: IO[AnyStr]) -> AsyncFile[AnyStr]:
194
+ """
195
+ Wrap an existing file as an asynchronous file.
196
+
197
+ :param file: an existing file-like object
198
+ :return: an asynchronous file object
199
+
200
+ """
201
+ return AsyncFile(file)
202
+
203
+
204
+ @dataclass(eq=False)
205
+ class _PathIterator(AsyncIterator["Path"]):
206
+ iterator: Iterator[PathLike[str]]
207
+
208
+ async def __anext__(self) -> Path:
209
+ nextval = await to_thread.run_sync(
210
+ next, self.iterator, None, abandon_on_cancel=True
211
+ )
212
+ if nextval is None:
213
+ raise StopAsyncIteration from None
214
+
215
+ return Path(nextval)
216
+
217
+
218
+ class Path:
219
+ """
220
+ An asynchronous version of :class:`pathlib.Path`.
221
+
222
+ This class cannot be substituted for :class:`pathlib.Path` or
223
+ :class:`pathlib.PurePath`, but it is compatible with the :class:`os.PathLike`
224
+ interface.
225
+
226
+ It implements the Python 3.10 version of :class:`pathlib.Path` interface, except for
227
+ the deprecated :meth:`~pathlib.Path.link_to` method.
228
+
229
+ Some methods may be unavailable or have limited functionality, based on the Python
230
+ version:
231
+
232
+ * :meth:`~pathlib.Path.copy` (available on Python 3.14 or later)
233
+ * :meth:`~pathlib.Path.copy_into` (available on Python 3.14 or later)
234
+ * :meth:`~pathlib.Path.from_uri` (available on Python 3.13 or later)
235
+ * :meth:`~pathlib.PurePath.full_match` (available on Python 3.13 or later)
236
+ * :attr:`~pathlib.Path.info` (available on Python 3.14 or later)
237
+ * :meth:`~pathlib.Path.is_junction` (available on Python 3.12 or later)
238
+ * :meth:`~pathlib.PurePath.match` (the ``case_sensitive`` parameter is only
239
+ available on Python 3.13 or later)
240
+ * :meth:`~pathlib.Path.move` (available on Python 3.14 or later)
241
+ * :meth:`~pathlib.Path.move_into` (available on Python 3.14 or later)
242
+ * :meth:`~pathlib.PurePath.relative_to` (the ``walk_up`` parameter is only available
243
+ on Python 3.12 or later)
244
+ * :meth:`~pathlib.Path.walk` (available on Python 3.12 or later)
245
+
246
+ Any methods that do disk I/O need to be awaited on. These methods are:
247
+
248
+ * :meth:`~pathlib.Path.absolute`
249
+ * :meth:`~pathlib.Path.chmod`
250
+ * :meth:`~pathlib.Path.cwd`
251
+ * :meth:`~pathlib.Path.exists`
252
+ * :meth:`~pathlib.Path.expanduser`
253
+ * :meth:`~pathlib.Path.group`
254
+ * :meth:`~pathlib.Path.hardlink_to`
255
+ * :meth:`~pathlib.Path.home`
256
+ * :meth:`~pathlib.Path.is_block_device`
257
+ * :meth:`~pathlib.Path.is_char_device`
258
+ * :meth:`~pathlib.Path.is_dir`
259
+ * :meth:`~pathlib.Path.is_fifo`
260
+ * :meth:`~pathlib.Path.is_file`
261
+ * :meth:`~pathlib.Path.is_junction`
262
+ * :meth:`~pathlib.Path.is_mount`
263
+ * :meth:`~pathlib.Path.is_socket`
264
+ * :meth:`~pathlib.Path.is_symlink`
265
+ * :meth:`~pathlib.Path.lchmod`
266
+ * :meth:`~pathlib.Path.lstat`
267
+ * :meth:`~pathlib.Path.mkdir`
268
+ * :meth:`~pathlib.Path.open`
269
+ * :meth:`~pathlib.Path.owner`
270
+ * :meth:`~pathlib.Path.read_bytes`
271
+ * :meth:`~pathlib.Path.read_text`
272
+ * :meth:`~pathlib.Path.readlink`
273
+ * :meth:`~pathlib.Path.rename`
274
+ * :meth:`~pathlib.Path.replace`
275
+ * :meth:`~pathlib.Path.resolve`
276
+ * :meth:`~pathlib.Path.rmdir`
277
+ * :meth:`~pathlib.Path.samefile`
278
+ * :meth:`~pathlib.Path.stat`
279
+ * :meth:`~pathlib.Path.symlink_to`
280
+ * :meth:`~pathlib.Path.touch`
281
+ * :meth:`~pathlib.Path.unlink`
282
+ * :meth:`~pathlib.Path.walk`
283
+ * :meth:`~pathlib.Path.write_bytes`
284
+ * :meth:`~pathlib.Path.write_text`
285
+
286
+ Additionally, the following methods return an async iterator yielding
287
+ :class:`~.Path` objects:
288
+
289
+ * :meth:`~pathlib.Path.glob`
290
+ * :meth:`~pathlib.Path.iterdir`
291
+ * :meth:`~pathlib.Path.rglob`
292
+ """
293
+
294
+ __slots__ = "_path", "__weakref__"
295
+
296
+ __weakref__: Any
297
+
298
+ def __init__(self, *args: str | PathLike[str]) -> None:
299
+ self._path: Final[pathlib.Path] = pathlib.Path(*args)
300
+
301
+ def __fspath__(self) -> str:
302
+ return self._path.__fspath__()
303
+
304
+ def __str__(self) -> str:
305
+ return self._path.__str__()
306
+
307
+ def __repr__(self) -> str:
308
+ return f"{self.__class__.__name__}({self.as_posix()!r})"
309
+
310
+ def __bytes__(self) -> bytes:
311
+ return self._path.__bytes__()
312
+
313
+ def __hash__(self) -> int:
314
+ return self._path.__hash__()
315
+
316
+ def __eq__(self, other: object) -> bool:
317
+ target = other._path if isinstance(other, Path) else other
318
+ return self._path.__eq__(target)
319
+
320
+ def __lt__(self, other: pathlib.PurePath | Path) -> bool:
321
+ target = other._path if isinstance(other, Path) else other
322
+ return self._path.__lt__(target)
323
+
324
+ def __le__(self, other: pathlib.PurePath | Path) -> bool:
325
+ target = other._path if isinstance(other, Path) else other
326
+ return self._path.__le__(target)
327
+
328
+ def __gt__(self, other: pathlib.PurePath | Path) -> bool:
329
+ target = other._path if isinstance(other, Path) else other
330
+ return self._path.__gt__(target)
331
+
332
+ def __ge__(self, other: pathlib.PurePath | Path) -> bool:
333
+ target = other._path if isinstance(other, Path) else other
334
+ return self._path.__ge__(target)
335
+
336
+ def __truediv__(self, other: str | PathLike[str]) -> Path:
337
+ return Path(self._path / other)
338
+
339
+ def __rtruediv__(self, other: str | PathLike[str]) -> Path:
340
+ return Path(other) / self
341
+
342
+ @property
343
+ def parts(self) -> tuple[str, ...]:
344
+ return self._path.parts
345
+
346
+ @property
347
+ def drive(self) -> str:
348
+ return self._path.drive
349
+
350
+ @property
351
+ def root(self) -> str:
352
+ return self._path.root
353
+
354
+ @property
355
+ def anchor(self) -> str:
356
+ return self._path.anchor
357
+
358
+ @property
359
+ def parents(self) -> Sequence[Path]:
360
+ return tuple(Path(p) for p in self._path.parents)
361
+
362
+ @property
363
+ def parent(self) -> Path:
364
+ return Path(self._path.parent)
365
+
366
+ @property
367
+ def name(self) -> str:
368
+ return self._path.name
369
+
370
+ @property
371
+ def suffix(self) -> str:
372
+ return self._path.suffix
373
+
374
+ @property
375
+ def suffixes(self) -> list[str]:
376
+ return self._path.suffixes
377
+
378
+ @property
379
+ def stem(self) -> str:
380
+ return self._path.stem
381
+
382
+ async def absolute(self) -> Path:
383
+ path = await to_thread.run_sync(self._path.absolute)
384
+ return Path(path)
385
+
386
+ def as_posix(self) -> str:
387
+ return self._path.as_posix()
388
+
389
+ def as_uri(self) -> str:
390
+ return self._path.as_uri()
391
+
392
+ if sys.version_info >= (3, 13):
393
+ parser: ClassVar[ModuleType] = pathlib.Path.parser
394
+
395
+ @classmethod
396
+ def from_uri(cls, uri: str) -> Path:
397
+ return Path(pathlib.Path.from_uri(uri))
398
+
399
+ def full_match(
400
+ self, path_pattern: str, *, case_sensitive: bool | None = None
401
+ ) -> bool:
402
+ return self._path.full_match(path_pattern, case_sensitive=case_sensitive)
403
+
404
+ def match(
405
+ self, path_pattern: str, *, case_sensitive: bool | None = None
406
+ ) -> bool:
407
+ return self._path.match(path_pattern, case_sensitive=case_sensitive)
408
+ else:
409
+
410
+ def match(self, path_pattern: str) -> bool:
411
+ return self._path.match(path_pattern)
412
+
413
+ if sys.version_info >= (3, 14):
414
+
415
+ @property
416
+ def info(self) -> Any: # TODO: add return type annotation when Typeshed gets it
417
+ return self._path.info
418
+
419
+ async def copy(
420
+ self,
421
+ target: str | os.PathLike[str],
422
+ *,
423
+ follow_symlinks: bool = True,
424
+ preserve_metadata: bool = False,
425
+ ) -> Path:
426
+ func = partial(
427
+ self._path.copy,
428
+ follow_symlinks=follow_symlinks,
429
+ preserve_metadata=preserve_metadata,
430
+ )
431
+ return Path(await to_thread.run_sync(func, pathlib.Path(target)))
432
+
433
+ async def copy_into(
434
+ self,
435
+ target_dir: str | os.PathLike[str],
436
+ *,
437
+ follow_symlinks: bool = True,
438
+ preserve_metadata: bool = False,
439
+ ) -> Path:
440
+ func = partial(
441
+ self._path.copy_into,
442
+ follow_symlinks=follow_symlinks,
443
+ preserve_metadata=preserve_metadata,
444
+ )
445
+ return Path(await to_thread.run_sync(func, pathlib.Path(target_dir)))
446
+
447
+ async def move(self, target: str | os.PathLike[str]) -> Path:
448
+ # Upstream does not handle anyio.Path properly as a PathLike
449
+ target = pathlib.Path(target)
450
+ return Path(await to_thread.run_sync(self._path.move, target))
451
+
452
+ async def move_into(
453
+ self,
454
+ target_dir: str | os.PathLike[str],
455
+ ) -> Path:
456
+ return Path(await to_thread.run_sync(self._path.move_into, target_dir))
457
+
458
+ def is_relative_to(self, other: str | PathLike[str]) -> bool:
459
+ try:
460
+ self.relative_to(other)
461
+ return True
462
+ except ValueError:
463
+ return False
464
+
465
+ async def chmod(self, mode: int, *, follow_symlinks: bool = True) -> None:
466
+ func = partial(os.chmod, follow_symlinks=follow_symlinks)
467
+ return await to_thread.run_sync(func, self._path, mode)
468
+
469
+ @classmethod
470
+ async def cwd(cls) -> Path:
471
+ path = await to_thread.run_sync(pathlib.Path.cwd)
472
+ return cls(path)
473
+
474
+ async def exists(self) -> bool:
475
+ return await to_thread.run_sync(self._path.exists, abandon_on_cancel=True)
476
+
477
+ async def expanduser(self) -> Path:
478
+ return Path(
479
+ await to_thread.run_sync(self._path.expanduser, abandon_on_cancel=True)
480
+ )
481
+
482
+ def glob(self, pattern: str) -> AsyncIterator[Path]:
483
+ gen = self._path.glob(pattern)
484
+ return _PathIterator(gen)
485
+
486
+ async def group(self) -> str:
487
+ return await to_thread.run_sync(self._path.group, abandon_on_cancel=True)
488
+
489
+ async def hardlink_to(
490
+ self, target: str | bytes | PathLike[str] | PathLike[bytes]
491
+ ) -> None:
492
+ if isinstance(target, Path):
493
+ target = target._path
494
+
495
+ await to_thread.run_sync(os.link, target, self)
496
+
497
+ @classmethod
498
+ async def home(cls) -> Path:
499
+ home_path = await to_thread.run_sync(pathlib.Path.home)
500
+ return cls(home_path)
501
+
502
+ def is_absolute(self) -> bool:
503
+ return self._path.is_absolute()
504
+
505
+ async def is_block_device(self) -> bool:
506
+ return await to_thread.run_sync(
507
+ self._path.is_block_device, abandon_on_cancel=True
508
+ )
509
+
510
+ async def is_char_device(self) -> bool:
511
+ return await to_thread.run_sync(
512
+ self._path.is_char_device, abandon_on_cancel=True
513
+ )
514
+
515
+ async def is_dir(self) -> bool:
516
+ return await to_thread.run_sync(self._path.is_dir, abandon_on_cancel=True)
517
+
518
+ async def is_fifo(self) -> bool:
519
+ return await to_thread.run_sync(self._path.is_fifo, abandon_on_cancel=True)
520
+
521
+ async def is_file(self) -> bool:
522
+ return await to_thread.run_sync(self._path.is_file, abandon_on_cancel=True)
523
+
524
+ if sys.version_info >= (3, 12):
525
+
526
+ async def is_junction(self) -> bool:
527
+ return await to_thread.run_sync(self._path.is_junction)
528
+
529
+ async def is_mount(self) -> bool:
530
+ return await to_thread.run_sync(
531
+ os.path.ismount, self._path, abandon_on_cancel=True
532
+ )
533
+
534
+ def is_reserved(self) -> bool:
535
+ return self._path.is_reserved()
536
+
537
+ async def is_socket(self) -> bool:
538
+ return await to_thread.run_sync(self._path.is_socket, abandon_on_cancel=True)
539
+
540
+ async def is_symlink(self) -> bool:
541
+ return await to_thread.run_sync(self._path.is_symlink, abandon_on_cancel=True)
542
+
543
+ async def iterdir(self) -> AsyncIterator[Path]:
544
+ gen = (
545
+ self._path.iterdir()
546
+ if sys.version_info < (3, 13)
547
+ else await to_thread.run_sync(self._path.iterdir, abandon_on_cancel=True)
548
+ )
549
+ async for path in _PathIterator(gen):
550
+ yield path
551
+
552
+ def joinpath(self, *args: str | PathLike[str]) -> Path:
553
+ return Path(self._path.joinpath(*args))
554
+
555
+ async def lchmod(self, mode: int) -> None:
556
+ await to_thread.run_sync(self._path.lchmod, mode)
557
+
558
+ async def lstat(self) -> os.stat_result:
559
+ return await to_thread.run_sync(self._path.lstat, abandon_on_cancel=True)
560
+
561
+ async def mkdir(
562
+ self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False
563
+ ) -> None:
564
+ await to_thread.run_sync(self._path.mkdir, mode, parents, exist_ok)
565
+
566
+ @overload
567
+ async def open(
568
+ self,
569
+ mode: OpenBinaryMode,
570
+ buffering: int = ...,
571
+ encoding: str | None = ...,
572
+ errors: str | None = ...,
573
+ newline: str | None = ...,
574
+ ) -> AsyncFile[bytes]: ...
575
+
576
+ @overload
577
+ async def open(
578
+ self,
579
+ mode: OpenTextMode = ...,
580
+ buffering: int = ...,
581
+ encoding: str | None = ...,
582
+ errors: str | None = ...,
583
+ newline: str | None = ...,
584
+ ) -> AsyncFile[str]: ...
585
+
586
+ async def open(
587
+ self,
588
+ mode: str = "r",
589
+ buffering: int = -1,
590
+ encoding: str | None = None,
591
+ errors: str | None = None,
592
+ newline: str | None = None,
593
+ ) -> AsyncFile[Any]:
594
+ fp = await to_thread.run_sync(
595
+ self._path.open, mode, buffering, encoding, errors, newline
596
+ )
597
+ return AsyncFile(fp)
598
+
599
+ async def owner(self) -> str:
600
+ return await to_thread.run_sync(self._path.owner, abandon_on_cancel=True)
601
+
602
+ async def read_bytes(self) -> bytes:
603
+ return await to_thread.run_sync(self._path.read_bytes)
604
+
605
+ async def read_text(
606
+ self, encoding: str | None = None, errors: str | None = None
607
+ ) -> str:
608
+ return await to_thread.run_sync(self._path.read_text, encoding, errors)
609
+
610
+ if sys.version_info >= (3, 12):
611
+
612
+ def relative_to(
613
+ self, *other: str | PathLike[str], walk_up: bool = False
614
+ ) -> Path:
615
+ # relative_to() should work with any PathLike but it doesn't
616
+ others = [pathlib.Path(other) for other in other]
617
+ return Path(self._path.relative_to(*others, walk_up=walk_up))
618
+
619
+ else:
620
+
621
+ def relative_to(self, *other: str | PathLike[str]) -> Path:
622
+ return Path(self._path.relative_to(*other))
623
+
624
+ async def readlink(self) -> Path:
625
+ target = await to_thread.run_sync(os.readlink, self._path)
626
+ return Path(target)
627
+
628
+ async def rename(self, target: str | pathlib.PurePath | Path) -> Path:
629
+ if isinstance(target, Path):
630
+ target = target._path
631
+
632
+ await to_thread.run_sync(self._path.rename, target)
633
+ return Path(target)
634
+
635
+ async def replace(self, target: str | pathlib.PurePath | Path) -> Path:
636
+ if isinstance(target, Path):
637
+ target = target._path
638
+
639
+ await to_thread.run_sync(self._path.replace, target)
640
+ return Path(target)
641
+
642
+ async def resolve(self, strict: bool = False) -> Path:
643
+ func = partial(self._path.resolve, strict=strict)
644
+ return Path(await to_thread.run_sync(func, abandon_on_cancel=True))
645
+
646
+ def rglob(self, pattern: str) -> AsyncIterator[Path]:
647
+ gen = self._path.rglob(pattern)
648
+ return _PathIterator(gen)
649
+
650
+ async def rmdir(self) -> None:
651
+ await to_thread.run_sync(self._path.rmdir)
652
+
653
+ async def samefile(self, other_path: str | PathLike[str]) -> bool:
654
+ if isinstance(other_path, Path):
655
+ other_path = other_path._path
656
+
657
+ return await to_thread.run_sync(
658
+ self._path.samefile, other_path, abandon_on_cancel=True
659
+ )
660
+
661
+ async def stat(self, *, follow_symlinks: bool = True) -> os.stat_result:
662
+ func = partial(os.stat, follow_symlinks=follow_symlinks)
663
+ return await to_thread.run_sync(func, self._path, abandon_on_cancel=True)
664
+
665
+ async def symlink_to(
666
+ self,
667
+ target: str | bytes | PathLike[str] | PathLike[bytes],
668
+ target_is_directory: bool = False,
669
+ ) -> None:
670
+ if isinstance(target, Path):
671
+ target = target._path
672
+
673
+ await to_thread.run_sync(self._path.symlink_to, target, target_is_directory)
674
+
675
+ async def touch(self, mode: int = 0o666, exist_ok: bool = True) -> None:
676
+ await to_thread.run_sync(self._path.touch, mode, exist_ok)
677
+
678
+ async def unlink(self, missing_ok: bool = False) -> None:
679
+ try:
680
+ await to_thread.run_sync(self._path.unlink)
681
+ except FileNotFoundError:
682
+ if not missing_ok:
683
+ raise
684
+
685
+ if sys.version_info >= (3, 12):
686
+
687
+ async def walk(
688
+ self,
689
+ top_down: bool = True,
690
+ on_error: Callable[[OSError], object] | None = None,
691
+ follow_symlinks: bool = False,
692
+ ) -> AsyncIterator[tuple[Path, list[str], list[str]]]:
693
+ def get_next_value() -> tuple[pathlib.Path, list[str], list[str]] | None:
694
+ try:
695
+ return next(gen)
696
+ except StopIteration:
697
+ return None
698
+
699
+ gen = self._path.walk(top_down, on_error, follow_symlinks)
700
+ while True:
701
+ value = await to_thread.run_sync(get_next_value)
702
+ if value is None:
703
+ return
704
+
705
+ root, dirs, paths = value
706
+ yield Path(root), dirs, paths
707
+
708
+ def with_name(self, name: str) -> Path:
709
+ return Path(self._path.with_name(name))
710
+
711
+ def with_stem(self, stem: str) -> Path:
712
+ return Path(self._path.with_name(stem + self._path.suffix))
713
+
714
+ def with_suffix(self, suffix: str) -> Path:
715
+ return Path(self._path.with_suffix(suffix))
716
+
717
+ def with_segments(self, *pathsegments: str | PathLike[str]) -> Path:
718
+ return Path(*pathsegments)
719
+
720
+ async def write_bytes(self, data: bytes) -> int:
721
+ return await to_thread.run_sync(self._path.write_bytes, data)
722
+
723
+ async def write_text(
724
+ self,
725
+ data: str,
726
+ encoding: str | None = None,
727
+ errors: str | None = None,
728
+ newline: str | None = None,
729
+ ) -> int:
730
+ # Path.write_text() does not support the "newline" parameter before Python 3.10
731
+ def sync_write_text() -> int:
732
+ with self._path.open(
733
+ "w", encoding=encoding, errors=errors, newline=newline
734
+ ) as fp:
735
+ return fp.write(data)
736
+
737
+ return await to_thread.run_sync(sync_write_text)
738
+
739
+
740
+ PathLike.register(Path)
miniconda3/lib/python3.13/site-packages/anyio/_core/_resources.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ..abc import AsyncResource
4
+ from ._tasks import CancelScope
5
+
6
+
7
+ async def aclose_forcefully(resource: AsyncResource) -> None:
8
+ """
9
+ Close an asynchronous resource in a cancelled scope.
10
+
11
+ Doing this closes the resource without waiting on anything.
12
+
13
+ :param resource: the resource to close
14
+
15
+ """
16
+ with CancelScope() as scope:
17
+ scope.cancel()
18
+ await resource.aclose()
miniconda3/lib/python3.13/site-packages/anyio/_core/_signals.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import AsyncIterator
4
+ from contextlib import AbstractContextManager
5
+ from signal import Signals
6
+
7
+ from ._eventloop import get_async_backend
8
+
9
+
10
+ def open_signal_receiver(
11
+ *signals: Signals,
12
+ ) -> AbstractContextManager[AsyncIterator[Signals]]:
13
+ """
14
+ Start receiving operating system signals.
15
+
16
+ :param signals: signals to receive (e.g. ``signal.SIGINT``)
17
+ :return: an asynchronous context manager for an asynchronous iterator which yields
18
+ signal numbers
19
+
20
+ .. warning:: Windows does not support signals natively so it is best to avoid
21
+ relying on this in cross-platform applications.
22
+
23
+ .. warning:: On asyncio, this permanently replaces any previous signal handler for
24
+ the given signals, as set via :meth:`~asyncio.loop.add_signal_handler`.
25
+
26
+ """
27
+ return get_async_backend().open_signal_receiver(*signals)
miniconda3/lib/python3.13/site-packages/anyio/_core/_sockets.py ADDED
@@ -0,0 +1,934 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import errno
4
+ import os
5
+ import socket
6
+ import ssl
7
+ import stat
8
+ import sys
9
+ from collections.abc import Awaitable
10
+ from dataclasses import dataclass
11
+ from ipaddress import IPv4Address, IPv6Address, ip_address
12
+ from os import PathLike, chmod
13
+ from socket import AddressFamily, SocketKind
14
+ from typing import TYPE_CHECKING, Any, Literal, cast, overload
15
+
16
+ from .. import ConnectionFailed, to_thread
17
+ from ..abc import (
18
+ ByteStreamConnectable,
19
+ ConnectedUDPSocket,
20
+ ConnectedUNIXDatagramSocket,
21
+ IPAddressType,
22
+ IPSockAddrType,
23
+ SocketListener,
24
+ SocketStream,
25
+ UDPSocket,
26
+ UNIXDatagramSocket,
27
+ UNIXSocketStream,
28
+ )
29
+ from ..streams.stapled import MultiListener
30
+ from ..streams.tls import TLSConnectable, TLSStream
31
+ from ._eventloop import get_async_backend
32
+ from ._resources import aclose_forcefully
33
+ from ._synchronization import Event
34
+ from ._tasks import create_task_group, move_on_after
35
+
36
+ if TYPE_CHECKING:
37
+ from _typeshed import FileDescriptorLike
38
+ else:
39
+ FileDescriptorLike = object
40
+
41
+ if sys.version_info < (3, 11):
42
+ from exceptiongroup import ExceptionGroup
43
+
44
+ if sys.version_info >= (3, 12):
45
+ from typing import override
46
+ else:
47
+ from typing_extensions import override
48
+
49
+ if sys.version_info < (3, 13):
50
+ from typing_extensions import deprecated
51
+ else:
52
+ from warnings import deprecated
53
+
54
+ IPPROTO_IPV6 = getattr(socket, "IPPROTO_IPV6", 41) # https://bugs.python.org/issue29515
55
+
56
+ AnyIPAddressFamily = Literal[
57
+ AddressFamily.AF_UNSPEC, AddressFamily.AF_INET, AddressFamily.AF_INET6
58
+ ]
59
+ IPAddressFamily = Literal[AddressFamily.AF_INET, AddressFamily.AF_INET6]
60
+
61
+
62
+ # tls_hostname given
63
+ @overload
64
+ async def connect_tcp(
65
+ remote_host: IPAddressType,
66
+ remote_port: int,
67
+ *,
68
+ local_host: IPAddressType | None = ...,
69
+ ssl_context: ssl.SSLContext | None = ...,
70
+ tls_standard_compatible: bool = ...,
71
+ tls_hostname: str,
72
+ happy_eyeballs_delay: float = ...,
73
+ ) -> TLSStream: ...
74
+
75
+
76
+ # ssl_context given
77
+ @overload
78
+ async def connect_tcp(
79
+ remote_host: IPAddressType,
80
+ remote_port: int,
81
+ *,
82
+ local_host: IPAddressType | None = ...,
83
+ ssl_context: ssl.SSLContext,
84
+ tls_standard_compatible: bool = ...,
85
+ tls_hostname: str | None = ...,
86
+ happy_eyeballs_delay: float = ...,
87
+ ) -> TLSStream: ...
88
+
89
+
90
+ # tls=True
91
+ @overload
92
+ async def connect_tcp(
93
+ remote_host: IPAddressType,
94
+ remote_port: int,
95
+ *,
96
+ local_host: IPAddressType | None = ...,
97
+ tls: Literal[True],
98
+ ssl_context: ssl.SSLContext | None = ...,
99
+ tls_standard_compatible: bool = ...,
100
+ tls_hostname: str | None = ...,
101
+ happy_eyeballs_delay: float = ...,
102
+ ) -> TLSStream: ...
103
+
104
+
105
+ # tls=False
106
+ @overload
107
+ async def connect_tcp(
108
+ remote_host: IPAddressType,
109
+ remote_port: int,
110
+ *,
111
+ local_host: IPAddressType | None = ...,
112
+ tls: Literal[False],
113
+ ssl_context: ssl.SSLContext | None = ...,
114
+ tls_standard_compatible: bool = ...,
115
+ tls_hostname: str | None = ...,
116
+ happy_eyeballs_delay: float = ...,
117
+ ) -> SocketStream: ...
118
+
119
+
120
+ # No TLS arguments
121
+ @overload
122
+ async def connect_tcp(
123
+ remote_host: IPAddressType,
124
+ remote_port: int,
125
+ *,
126
+ local_host: IPAddressType | None = ...,
127
+ happy_eyeballs_delay: float = ...,
128
+ ) -> SocketStream: ...
129
+
130
+
131
+ async def connect_tcp(
132
+ remote_host: IPAddressType,
133
+ remote_port: int,
134
+ *,
135
+ local_host: IPAddressType | None = None,
136
+ tls: bool = False,
137
+ ssl_context: ssl.SSLContext | None = None,
138
+ tls_standard_compatible: bool = True,
139
+ tls_hostname: str | None = None,
140
+ happy_eyeballs_delay: float = 0.25,
141
+ ) -> SocketStream | TLSStream:
142
+ """
143
+ Connect to a host using the TCP protocol.
144
+
145
+ This function implements the stateless version of the Happy Eyeballs algorithm (RFC
146
+ 6555). If ``remote_host`` is a host name that resolves to multiple IP addresses,
147
+ each one is tried until one connection attempt succeeds. If the first attempt does
148
+ not connected within 250 milliseconds, a second attempt is started using the next
149
+ address in the list, and so on. On IPv6 enabled systems, an IPv6 address (if
150
+ available) is tried first.
151
+
152
+ When the connection has been established, a TLS handshake will be done if either
153
+ ``ssl_context`` or ``tls_hostname`` is not ``None``, or if ``tls`` is ``True``.
154
+
155
+ :param remote_host: the IP address or host name to connect to
156
+ :param remote_port: port on the target host to connect to
157
+ :param local_host: the interface address or name to bind the socket to before
158
+ connecting
159
+ :param tls: ``True`` to do a TLS handshake with the connected stream and return a
160
+ :class:`~anyio.streams.tls.TLSStream` instead
161
+ :param ssl_context: the SSL context object to use (if omitted, a default context is
162
+ created)
163
+ :param tls_standard_compatible: If ``True``, performs the TLS shutdown handshake
164
+ before closing the stream and requires that the server does this as well.
165
+ Otherwise, :exc:`~ssl.SSLEOFError` may be raised during reads from the stream.
166
+ Some protocols, such as HTTP, require this option to be ``False``.
167
+ See :meth:`~ssl.SSLContext.wrap_socket` for details.
168
+ :param tls_hostname: host name to check the server certificate against (defaults to
169
+ the value of ``remote_host``)
170
+ :param happy_eyeballs_delay: delay (in seconds) before starting the next connection
171
+ attempt
172
+ :return: a socket stream object if no TLS handshake was done, otherwise a TLS stream
173
+ :raises ConnectionFailed: if the connection fails
174
+
175
+ """
176
+ # Placed here due to https://github.com/python/mypy/issues/7057
177
+ connected_stream: SocketStream | None = None
178
+
179
+ async def try_connect(remote_host: str, event: Event) -> None:
180
+ nonlocal connected_stream
181
+ try:
182
+ stream = await asynclib.connect_tcp(remote_host, remote_port, local_address)
183
+ except OSError as exc:
184
+ oserrors.append(exc)
185
+ return
186
+ else:
187
+ if connected_stream is None:
188
+ connected_stream = stream
189
+ tg.cancel_scope.cancel()
190
+ else:
191
+ await stream.aclose()
192
+ finally:
193
+ event.set()
194
+
195
+ asynclib = get_async_backend()
196
+ local_address: IPSockAddrType | None = None
197
+ family = socket.AF_UNSPEC
198
+ if local_host:
199
+ gai_res = await getaddrinfo(str(local_host), None)
200
+ family, *_, local_address = gai_res[0]
201
+
202
+ target_host = str(remote_host)
203
+ try:
204
+ addr_obj = ip_address(remote_host)
205
+ except ValueError:
206
+ addr_obj = None
207
+
208
+ if addr_obj is not None:
209
+ if isinstance(addr_obj, IPv6Address):
210
+ target_addrs = [(socket.AF_INET6, addr_obj.compressed)]
211
+ else:
212
+ target_addrs = [(socket.AF_INET, addr_obj.compressed)]
213
+ else:
214
+ # getaddrinfo() will raise an exception if name resolution fails
215
+ gai_res = await getaddrinfo(
216
+ target_host, remote_port, family=family, type=socket.SOCK_STREAM
217
+ )
218
+
219
+ # Organize the list so that the first address is an IPv6 address (if available)
220
+ # and the second one is an IPv4 addresses. The rest can be in whatever order.
221
+ v6_found = v4_found = False
222
+ target_addrs = []
223
+ for af, *_, sa in gai_res:
224
+ if af == socket.AF_INET6 and not v6_found:
225
+ v6_found = True
226
+ target_addrs.insert(0, (af, sa[0]))
227
+ elif af == socket.AF_INET and not v4_found and v6_found:
228
+ v4_found = True
229
+ target_addrs.insert(1, (af, sa[0]))
230
+ else:
231
+ target_addrs.append((af, sa[0]))
232
+
233
+ oserrors: list[OSError] = []
234
+ try:
235
+ async with create_task_group() as tg:
236
+ for _af, addr in target_addrs:
237
+ event = Event()
238
+ tg.start_soon(try_connect, addr, event)
239
+ with move_on_after(happy_eyeballs_delay):
240
+ await event.wait()
241
+
242
+ if connected_stream is None:
243
+ cause = (
244
+ oserrors[0]
245
+ if len(oserrors) == 1
246
+ else ExceptionGroup("multiple connection attempts failed", oserrors)
247
+ )
248
+ raise OSError("All connection attempts failed") from cause
249
+ finally:
250
+ oserrors.clear()
251
+
252
+ if tls or tls_hostname or ssl_context:
253
+ try:
254
+ return await TLSStream.wrap(
255
+ connected_stream,
256
+ server_side=False,
257
+ hostname=tls_hostname or str(remote_host),
258
+ ssl_context=ssl_context,
259
+ standard_compatible=tls_standard_compatible,
260
+ )
261
+ except BaseException:
262
+ await aclose_forcefully(connected_stream)
263
+ raise
264
+
265
+ return connected_stream
266
+
267
+
268
+ async def connect_unix(path: str | bytes | PathLike[Any]) -> UNIXSocketStream:
269
+ """
270
+ Connect to the given UNIX socket.
271
+
272
+ Not available on Windows.
273
+
274
+ :param path: path to the socket
275
+ :return: a socket stream object
276
+ :raises ConnectionFailed: if the connection fails
277
+
278
+ """
279
+ path = os.fspath(path)
280
+ return await get_async_backend().connect_unix(path)
281
+
282
+
283
+ async def create_tcp_listener(
284
+ *,
285
+ local_host: IPAddressType | None = None,
286
+ local_port: int = 0,
287
+ family: AnyIPAddressFamily = socket.AddressFamily.AF_UNSPEC,
288
+ backlog: int = 65536,
289
+ reuse_port: bool = False,
290
+ ) -> MultiListener[SocketStream]:
291
+ """
292
+ Create a TCP socket listener.
293
+
294
+ :param local_port: port number to listen on
295
+ :param local_host: IP address of the interface to listen on. If omitted, listen on
296
+ all IPv4 and IPv6 interfaces. To listen on all interfaces on a specific address
297
+ family, use ``0.0.0.0`` for IPv4 or ``::`` for IPv6.
298
+ :param family: address family (used if ``local_host`` was omitted)
299
+ :param backlog: maximum number of queued incoming connections (up to a maximum of
300
+ 2**16, or 65536)
301
+ :param reuse_port: ``True`` to allow multiple sockets to bind to the same
302
+ address/port (not supported on Windows)
303
+ :return: a multi-listener object containing one or more socket listeners
304
+
305
+ """
306
+ asynclib = get_async_backend()
307
+ backlog = min(backlog, 65536)
308
+ local_host = str(local_host) if local_host is not None else None
309
+ gai_res = await getaddrinfo(
310
+ local_host,
311
+ local_port,
312
+ family=family,
313
+ type=socket.SocketKind.SOCK_STREAM if sys.platform == "win32" else 0,
314
+ flags=socket.AI_PASSIVE | socket.AI_ADDRCONFIG,
315
+ )
316
+ listeners: list[SocketListener] = []
317
+ try:
318
+ # The set() is here to work around a glibc bug:
319
+ # https://sourceware.org/bugzilla/show_bug.cgi?id=14969
320
+ sockaddr: tuple[str, int] | tuple[str, int, int, int]
321
+ for fam, kind, *_, sockaddr in sorted(set(gai_res)):
322
+ # Workaround for an uvloop bug where we don't get the correct scope ID for
323
+ # IPv6 link-local addresses when passing type=socket.SOCK_STREAM to
324
+ # getaddrinfo(): https://github.com/MagicStack/uvloop/issues/539
325
+ if sys.platform != "win32" and kind is not SocketKind.SOCK_STREAM:
326
+ continue
327
+
328
+ raw_socket = socket.socket(fam)
329
+ raw_socket.setblocking(False)
330
+
331
+ # For Windows, enable exclusive address use. For others, enable address
332
+ # reuse.
333
+ if sys.platform == "win32":
334
+ raw_socket.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1)
335
+ else:
336
+ raw_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
337
+
338
+ if reuse_port:
339
+ raw_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
340
+
341
+ # If only IPv6 was requested, disable dual stack operation
342
+ if fam == socket.AF_INET6:
343
+ raw_socket.setsockopt(IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
344
+
345
+ # Workaround for #554
346
+ if "%" in sockaddr[0]:
347
+ addr, scope_id = sockaddr[0].split("%", 1)
348
+ sockaddr = (addr, sockaddr[1], 0, int(scope_id))
349
+
350
+ raw_socket.bind(sockaddr)
351
+ raw_socket.listen(backlog)
352
+ listener = asynclib.create_tcp_listener(raw_socket)
353
+ listeners.append(listener)
354
+ except BaseException:
355
+ for listener in listeners:
356
+ await listener.aclose()
357
+
358
+ raise
359
+
360
+ return MultiListener(listeners)
361
+
362
+
363
+ async def create_unix_listener(
364
+ path: str | bytes | PathLike[Any],
365
+ *,
366
+ mode: int | None = None,
367
+ backlog: int = 65536,
368
+ ) -> SocketListener:
369
+ """
370
+ Create a UNIX socket listener.
371
+
372
+ Not available on Windows.
373
+
374
+ :param path: path of the socket
375
+ :param mode: permissions to set on the socket
376
+ :param backlog: maximum number of queued incoming connections (up to a maximum of
377
+ 2**16, or 65536)
378
+ :return: a listener object
379
+
380
+ .. versionchanged:: 3.0
381
+ If a socket already exists on the file system in the given path, it will be
382
+ removed first.
383
+
384
+ """
385
+ backlog = min(backlog, 65536)
386
+ raw_socket = await setup_unix_local_socket(path, mode, socket.SOCK_STREAM)
387
+ try:
388
+ raw_socket.listen(backlog)
389
+ return get_async_backend().create_unix_listener(raw_socket)
390
+ except BaseException:
391
+ raw_socket.close()
392
+ raise
393
+
394
+
395
+ async def create_udp_socket(
396
+ family: AnyIPAddressFamily = AddressFamily.AF_UNSPEC,
397
+ *,
398
+ local_host: IPAddressType | None = None,
399
+ local_port: int = 0,
400
+ reuse_port: bool = False,
401
+ ) -> UDPSocket:
402
+ """
403
+ Create a UDP socket.
404
+
405
+ If ``port`` has been given, the socket will be bound to this port on the local
406
+ machine, making this socket suitable for providing UDP based services.
407
+
408
+ :param family: address family (``AF_INET`` or ``AF_INET6``) – automatically
409
+ determined from ``local_host`` if omitted
410
+ :param local_host: IP address or host name of the local interface to bind to
411
+ :param local_port: local port to bind to
412
+ :param reuse_port: ``True`` to allow multiple sockets to bind to the same
413
+ address/port (not supported on Windows)
414
+ :return: a UDP socket
415
+
416
+ """
417
+ if family is AddressFamily.AF_UNSPEC and not local_host:
418
+ raise ValueError('Either "family" or "local_host" must be given')
419
+
420
+ if local_host:
421
+ gai_res = await getaddrinfo(
422
+ str(local_host),
423
+ local_port,
424
+ family=family,
425
+ type=socket.SOCK_DGRAM,
426
+ flags=socket.AI_PASSIVE | socket.AI_ADDRCONFIG,
427
+ )
428
+ family = cast(AnyIPAddressFamily, gai_res[0][0])
429
+ local_address = gai_res[0][-1]
430
+ elif family is AddressFamily.AF_INET6:
431
+ local_address = ("::", 0)
432
+ else:
433
+ local_address = ("0.0.0.0", 0)
434
+
435
+ sock = await get_async_backend().create_udp_socket(
436
+ family, local_address, None, reuse_port
437
+ )
438
+ return cast(UDPSocket, sock)
439
+
440
+
441
+ async def create_connected_udp_socket(
442
+ remote_host: IPAddressType,
443
+ remote_port: int,
444
+ *,
445
+ family: AnyIPAddressFamily = AddressFamily.AF_UNSPEC,
446
+ local_host: IPAddressType | None = None,
447
+ local_port: int = 0,
448
+ reuse_port: bool = False,
449
+ ) -> ConnectedUDPSocket:
450
+ """
451
+ Create a connected UDP socket.
452
+
453
+ Connected UDP sockets can only communicate with the specified remote host/port, an
454
+ any packets sent from other sources are dropped.
455
+
456
+ :param remote_host: remote host to set as the default target
457
+ :param remote_port: port on the remote host to set as the default target
458
+ :param family: address family (``AF_INET`` or ``AF_INET6``) – automatically
459
+ determined from ``local_host`` or ``remote_host`` if omitted
460
+ :param local_host: IP address or host name of the local interface to bind to
461
+ :param local_port: local port to bind to
462
+ :param reuse_port: ``True`` to allow multiple sockets to bind to the same
463
+ address/port (not supported on Windows)
464
+ :return: a connected UDP socket
465
+
466
+ """
467
+ local_address = None
468
+ if local_host:
469
+ gai_res = await getaddrinfo(
470
+ str(local_host),
471
+ local_port,
472
+ family=family,
473
+ type=socket.SOCK_DGRAM,
474
+ flags=socket.AI_PASSIVE | socket.AI_ADDRCONFIG,
475
+ )
476
+ family = cast(AnyIPAddressFamily, gai_res[0][0])
477
+ local_address = gai_res[0][-1]
478
+
479
+ gai_res = await getaddrinfo(
480
+ str(remote_host), remote_port, family=family, type=socket.SOCK_DGRAM
481
+ )
482
+ family = cast(AnyIPAddressFamily, gai_res[0][0])
483
+ remote_address = gai_res[0][-1]
484
+
485
+ sock = await get_async_backend().create_udp_socket(
486
+ family, local_address, remote_address, reuse_port
487
+ )
488
+ return cast(ConnectedUDPSocket, sock)
489
+
490
+
491
+ async def create_unix_datagram_socket(
492
+ *,
493
+ local_path: None | str | bytes | PathLike[Any] = None,
494
+ local_mode: int | None = None,
495
+ ) -> UNIXDatagramSocket:
496
+ """
497
+ Create a UNIX datagram socket.
498
+
499
+ Not available on Windows.
500
+
501
+ If ``local_path`` has been given, the socket will be bound to this path, making this
502
+ socket suitable for receiving datagrams from other processes. Other processes can
503
+ send datagrams to this socket only if ``local_path`` is set.
504
+
505
+ If a socket already exists on the file system in the ``local_path``, it will be
506
+ removed first.
507
+
508
+ :param local_path: the path on which to bind to
509
+ :param local_mode: permissions to set on the local socket
510
+ :return: a UNIX datagram socket
511
+
512
+ """
513
+ raw_socket = await setup_unix_local_socket(
514
+ local_path, local_mode, socket.SOCK_DGRAM
515
+ )
516
+ return await get_async_backend().create_unix_datagram_socket(raw_socket, None)
517
+
518
+
519
+ async def create_connected_unix_datagram_socket(
520
+ remote_path: str | bytes | PathLike[Any],
521
+ *,
522
+ local_path: None | str | bytes | PathLike[Any] = None,
523
+ local_mode: int | None = None,
524
+ ) -> ConnectedUNIXDatagramSocket:
525
+ """
526
+ Create a connected UNIX datagram socket.
527
+
528
+ Connected datagram sockets can only communicate with the specified remote path.
529
+
530
+ If ``local_path`` has been given, the socket will be bound to this path, making
531
+ this socket suitable for receiving datagrams from other processes. Other processes
532
+ can send datagrams to this socket only if ``local_path`` is set.
533
+
534
+ If a socket already exists on the file system in the ``local_path``, it will be
535
+ removed first.
536
+
537
+ :param remote_path: the path to set as the default target
538
+ :param local_path: the path on which to bind to
539
+ :param local_mode: permissions to set on the local socket
540
+ :return: a connected UNIX datagram socket
541
+
542
+ """
543
+ remote_path = os.fspath(remote_path)
544
+ raw_socket = await setup_unix_local_socket(
545
+ local_path, local_mode, socket.SOCK_DGRAM
546
+ )
547
+ return await get_async_backend().create_unix_datagram_socket(
548
+ raw_socket, remote_path
549
+ )
550
+
551
+
552
+ async def getaddrinfo(
553
+ host: bytes | str | None,
554
+ port: str | int | None,
555
+ *,
556
+ family: int | AddressFamily = 0,
557
+ type: int | SocketKind = 0,
558
+ proto: int = 0,
559
+ flags: int = 0,
560
+ ) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int]]]:
561
+ """
562
+ Look up a numeric IP address given a host name.
563
+
564
+ Internationalized domain names are translated according to the (non-transitional)
565
+ IDNA 2008 standard.
566
+
567
+ .. note:: 4-tuple IPv6 socket addresses are automatically converted to 2-tuples of
568
+ (host, port), unlike what :func:`socket.getaddrinfo` does.
569
+
570
+ :param host: host name
571
+ :param port: port number
572
+ :param family: socket family (`'AF_INET``, ...)
573
+ :param type: socket type (``SOCK_STREAM``, ...)
574
+ :param proto: protocol number
575
+ :param flags: flags to pass to upstream ``getaddrinfo()``
576
+ :return: list of tuples containing (family, type, proto, canonname, sockaddr)
577
+
578
+ .. seealso:: :func:`socket.getaddrinfo`
579
+
580
+ """
581
+ # Handle unicode hostnames
582
+ if isinstance(host, str):
583
+ try:
584
+ encoded_host: bytes | None = host.encode("ascii")
585
+ except UnicodeEncodeError:
586
+ import idna
587
+
588
+ encoded_host = idna.encode(host, uts46=True)
589
+ else:
590
+ encoded_host = host
591
+
592
+ gai_res = await get_async_backend().getaddrinfo(
593
+ encoded_host, port, family=family, type=type, proto=proto, flags=flags
594
+ )
595
+ return [
596
+ (family, type, proto, canonname, convert_ipv6_sockaddr(sockaddr))
597
+ for family, type, proto, canonname, sockaddr in gai_res
598
+ # filter out IPv6 results when IPv6 is disabled
599
+ if not isinstance(sockaddr[0], int)
600
+ ]
601
+
602
+
603
+ def getnameinfo(sockaddr: IPSockAddrType, flags: int = 0) -> Awaitable[tuple[str, str]]:
604
+ """
605
+ Look up the host name of an IP address.
606
+
607
+ :param sockaddr: socket address (e.g. (ipaddress, port) for IPv4)
608
+ :param flags: flags to pass to upstream ``getnameinfo()``
609
+ :return: a tuple of (host name, service name)
610
+
611
+ .. seealso:: :func:`socket.getnameinfo`
612
+
613
+ """
614
+ return get_async_backend().getnameinfo(sockaddr, flags)
615
+
616
+
617
+ @deprecated("This function is deprecated; use `wait_readable` instead")
618
+ def wait_socket_readable(sock: socket.socket) -> Awaitable[None]:
619
+ """
620
+ .. deprecated:: 4.7.0
621
+ Use :func:`wait_readable` instead.
622
+
623
+ Wait until the given socket has data to be read.
624
+
625
+ .. warning:: Only use this on raw sockets that have not been wrapped by any higher
626
+ level constructs like socket streams!
627
+
628
+ :param sock: a socket object
629
+ :raises ~anyio.ClosedResourceError: if the socket was closed while waiting for the
630
+ socket to become readable
631
+ :raises ~anyio.BusyResourceError: if another task is already waiting for the socket
632
+ to become readable
633
+
634
+ """
635
+ return get_async_backend().wait_readable(sock.fileno())
636
+
637
+
638
+ @deprecated("This function is deprecated; use `wait_writable` instead")
639
+ def wait_socket_writable(sock: socket.socket) -> Awaitable[None]:
640
+ """
641
+ .. deprecated:: 4.7.0
642
+ Use :func:`wait_writable` instead.
643
+
644
+ Wait until the given socket can be written to.
645
+
646
+ This does **NOT** work on Windows when using the asyncio backend with a proactor
647
+ event loop (default on py3.8+).
648
+
649
+ .. warning:: Only use this on raw sockets that have not been wrapped by any higher
650
+ level constructs like socket streams!
651
+
652
+ :param sock: a socket object
653
+ :raises ~anyio.ClosedResourceError: if the socket was closed while waiting for the
654
+ socket to become writable
655
+ :raises ~anyio.BusyResourceError: if another task is already waiting for the socket
656
+ to become writable
657
+
658
+ """
659
+ return get_async_backend().wait_writable(sock.fileno())
660
+
661
+
662
+ def wait_readable(obj: FileDescriptorLike) -> Awaitable[None]:
663
+ """
664
+ Wait until the given object has data to be read.
665
+
666
+ On Unix systems, ``obj`` must either be an integer file descriptor, or else an
667
+ object with a ``.fileno()`` method which returns an integer file descriptor. Any
668
+ kind of file descriptor can be passed, though the exact semantics will depend on
669
+ your kernel. For example, this probably won't do anything useful for on-disk files.
670
+
671
+ On Windows systems, ``obj`` must either be an integer ``SOCKET`` handle, or else an
672
+ object with a ``.fileno()`` method which returns an integer ``SOCKET`` handle. File
673
+ descriptors aren't supported, and neither are handles that refer to anything besides
674
+ a ``SOCKET``.
675
+
676
+ On backends where this functionality is not natively provided (asyncio
677
+ ``ProactorEventLoop`` on Windows), it is provided using a separate selector thread
678
+ which is set to shut down when the interpreter shuts down.
679
+
680
+ .. warning:: Don't use this on raw sockets that have been wrapped by any higher
681
+ level constructs like socket streams!
682
+
683
+ :param obj: an object with a ``.fileno()`` method or an integer handle
684
+ :raises ~anyio.ClosedResourceError: if the object was closed while waiting for the
685
+ object to become readable
686
+ :raises ~anyio.BusyResourceError: if another task is already waiting for the object
687
+ to become readable
688
+
689
+ """
690
+ return get_async_backend().wait_readable(obj)
691
+
692
+
693
+ def wait_writable(obj: FileDescriptorLike) -> Awaitable[None]:
694
+ """
695
+ Wait until the given object can be written to.
696
+
697
+ :param obj: an object with a ``.fileno()`` method or an integer handle
698
+ :raises ~anyio.ClosedResourceError: if the object was closed while waiting for the
699
+ object to become writable
700
+ :raises ~anyio.BusyResourceError: if another task is already waiting for the object
701
+ to become writable
702
+
703
+ .. seealso:: See the documentation of :func:`wait_readable` for the definition of
704
+ ``obj`` and notes on backend compatibility.
705
+
706
+ .. warning:: Don't use this on raw sockets that have been wrapped by any higher
707
+ level constructs like socket streams!
708
+
709
+ """
710
+ return get_async_backend().wait_writable(obj)
711
+
712
+
713
+ def notify_closing(obj: FileDescriptorLike) -> None:
714
+ """
715
+ Call this before closing a file descriptor (on Unix) or socket (on
716
+ Windows). This will cause any `wait_readable` or `wait_writable`
717
+ calls on the given object to immediately wake up and raise
718
+ `~anyio.ClosedResourceError`.
719
+
720
+ This doesn't actually close the object – you still have to do that
721
+ yourself afterwards. Also, you want to be careful to make sure no
722
+ new tasks start waiting on the object in between when you call this
723
+ and when it's actually closed. So to close something properly, you
724
+ usually want to do these steps in order:
725
+
726
+ 1. Explicitly mark the object as closed, so that any new attempts
727
+ to use it will abort before they start.
728
+ 2. Call `notify_closing` to wake up any already-existing users.
729
+ 3. Actually close the object.
730
+
731
+ It's also possible to do them in a different order if that's more
732
+ convenient, *but only if* you make sure not to have any checkpoints in
733
+ between the steps. This way they all happen in a single atomic
734
+ step, so other tasks won't be able to tell what order they happened
735
+ in anyway.
736
+
737
+ :param obj: an object with a ``.fileno()`` method or an integer handle
738
+
739
+ """
740
+ get_async_backend().notify_closing(obj)
741
+
742
+
743
+ #
744
+ # Private API
745
+ #
746
+
747
+
748
+ def convert_ipv6_sockaddr(
749
+ sockaddr: tuple[str, int, int, int] | tuple[str, int],
750
+ ) -> tuple[str, int]:
751
+ """
752
+ Convert a 4-tuple IPv6 socket address to a 2-tuple (address, port) format.
753
+
754
+ If the scope ID is nonzero, it is added to the address, separated with ``%``.
755
+ Otherwise the flow id and scope id are simply cut off from the tuple.
756
+ Any other kinds of socket addresses are returned as-is.
757
+
758
+ :param sockaddr: the result of :meth:`~socket.socket.getsockname`
759
+ :return: the converted socket address
760
+
761
+ """
762
+ # This is more complicated than it should be because of MyPy
763
+ if isinstance(sockaddr, tuple) and len(sockaddr) == 4:
764
+ host, port, flowinfo, scope_id = sockaddr
765
+ if scope_id:
766
+ # PyPy (as of v7.3.11) leaves the interface name in the result, so
767
+ # we discard it and only get the scope ID from the end
768
+ # (https://foss.heptapod.net/pypy/pypy/-/issues/3938)
769
+ host = host.split("%")[0]
770
+
771
+ # Add scope_id to the address
772
+ return f"{host}%{scope_id}", port
773
+ else:
774
+ return host, port
775
+ else:
776
+ return sockaddr
777
+
778
+
779
+ async def setup_unix_local_socket(
780
+ path: None | str | bytes | PathLike[Any],
781
+ mode: int | None,
782
+ socktype: int,
783
+ ) -> socket.socket:
784
+ """
785
+ Create a UNIX local socket object, deleting the socket at the given path if it
786
+ exists.
787
+
788
+ Not available on Windows.
789
+
790
+ :param path: path of the socket
791
+ :param mode: permissions to set on the socket
792
+ :param socktype: socket.SOCK_STREAM or socket.SOCK_DGRAM
793
+
794
+ """
795
+ path_str: str | None
796
+ if path is not None:
797
+ path_str = os.fsdecode(path)
798
+
799
+ # Linux abstract namespace sockets aren't backed by a concrete file so skip stat call
800
+ if not path_str.startswith("\0"):
801
+ # Copied from pathlib...
802
+ try:
803
+ stat_result = os.stat(path)
804
+ except OSError as e:
805
+ if e.errno not in (
806
+ errno.ENOENT,
807
+ errno.ENOTDIR,
808
+ errno.EBADF,
809
+ errno.ELOOP,
810
+ ):
811
+ raise
812
+ else:
813
+ if stat.S_ISSOCK(stat_result.st_mode):
814
+ os.unlink(path)
815
+ else:
816
+ path_str = None
817
+
818
+ raw_socket = socket.socket(socket.AF_UNIX, socktype)
819
+ raw_socket.setblocking(False)
820
+
821
+ if path_str is not None:
822
+ try:
823
+ await to_thread.run_sync(raw_socket.bind, path_str, abandon_on_cancel=True)
824
+ if mode is not None:
825
+ await to_thread.run_sync(chmod, path_str, mode, abandon_on_cancel=True)
826
+ except BaseException:
827
+ raw_socket.close()
828
+ raise
829
+
830
+ return raw_socket
831
+
832
+
833
+ @dataclass
834
+ class TCPConnectable(ByteStreamConnectable):
835
+ """
836
+ Connects to a TCP server at the given host and port.
837
+
838
+ :param host: host name or IP address of the server
839
+ :param port: TCP port number of the server
840
+ """
841
+
842
+ host: str | IPv4Address | IPv6Address
843
+ port: int
844
+
845
+ def __post_init__(self) -> None:
846
+ if self.port < 1 or self.port > 65535:
847
+ raise ValueError("TCP port number out of range")
848
+
849
+ @override
850
+ async def connect(self) -> SocketStream:
851
+ try:
852
+ return await connect_tcp(self.host, self.port)
853
+ except OSError as exc:
854
+ raise ConnectionFailed(
855
+ f"error connecting to {self.host}:{self.port}: {exc}"
856
+ ) from exc
857
+
858
+
859
+ @dataclass
860
+ class UNIXConnectable(ByteStreamConnectable):
861
+ """
862
+ Connects to a UNIX domain socket at the given path.
863
+
864
+ :param path: the file system path of the socket
865
+ """
866
+
867
+ path: str | bytes | PathLike[str] | PathLike[bytes]
868
+
869
+ @override
870
+ async def connect(self) -> UNIXSocketStream:
871
+ try:
872
+ return await connect_unix(self.path)
873
+ except OSError as exc:
874
+ raise ConnectionFailed(f"error connecting to {self.path!r}: {exc}") from exc
875
+
876
+
877
+ def as_connectable(
878
+ remote: ByteStreamConnectable
879
+ | tuple[str | IPv4Address | IPv6Address, int]
880
+ | str
881
+ | bytes
882
+ | PathLike[str],
883
+ /,
884
+ *,
885
+ tls: bool = False,
886
+ ssl_context: ssl.SSLContext | None = None,
887
+ tls_hostname: str | None = None,
888
+ tls_standard_compatible: bool = True,
889
+ ) -> ByteStreamConnectable:
890
+ """
891
+ Return a byte stream connectable from the given object.
892
+
893
+ If a bytestream connectable is given, it is returned unchanged.
894
+ If a tuple of (host, port) is given, a TCP connectable is returned.
895
+ If a string or bytes path is given, a UNIX connectable is returned.
896
+
897
+ If ``tls=True``, the connectable will be wrapped in a
898
+ :class:`~.streams.tls.TLSConnectable`.
899
+
900
+ :param remote: a connectable, a tuple of (host, port) or a path to a UNIX socket
901
+ :param tls: if ``True``, wrap the plaintext connectable in a
902
+ :class:`~.streams.tls.TLSConnectable`, using the provided TLS settings)
903
+ :param ssl_context: if ``tls=True``, the SSLContext object to use (if not provided,
904
+ a secure default will be created)
905
+ :param tls_hostname: if ``tls=True``, host name of the server to use for checking
906
+ the server certificate (defaults to the host portion of the address for TCP
907
+ connectables)
908
+ :param tls_standard_compatible: if ``False`` and ``tls=True``, makes the TLS stream
909
+ skip the closing handshake when closing the connection, so it won't raise an
910
+ exception if the server does the same
911
+
912
+ """
913
+ connectable: TCPConnectable | UNIXConnectable | TLSConnectable
914
+ if isinstance(remote, ByteStreamConnectable):
915
+ return remote
916
+ elif isinstance(remote, tuple) and len(remote) == 2:
917
+ connectable = TCPConnectable(*remote)
918
+ elif isinstance(remote, (str, bytes, PathLike)):
919
+ connectable = UNIXConnectable(remote)
920
+ else:
921
+ raise TypeError(f"cannot convert {remote!r} to a connectable")
922
+
923
+ if tls:
924
+ if not tls_hostname and isinstance(connectable, TCPConnectable):
925
+ tls_hostname = str(connectable.host)
926
+
927
+ connectable = TLSConnectable(
928
+ connectable,
929
+ ssl_context=ssl_context,
930
+ hostname=tls_hostname,
931
+ standard_compatible=tls_standard_compatible,
932
+ )
933
+
934
+ return connectable
miniconda3/lib/python3.13/site-packages/anyio/_core/_streams.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import math
4
+ from typing import TypeVar
5
+ from warnings import warn
6
+
7
+ from ..streams.memory import (
8
+ MemoryObjectReceiveStream,
9
+ MemoryObjectSendStream,
10
+ MemoryObjectStreamState,
11
+ )
12
+
13
+ T_Item = TypeVar("T_Item")
14
+
15
+
16
+ class create_memory_object_stream(
17
+ tuple[MemoryObjectSendStream[T_Item], MemoryObjectReceiveStream[T_Item]],
18
+ ):
19
+ """
20
+ Create a memory object stream.
21
+
22
+ The stream's item type can be annotated like
23
+ :func:`create_memory_object_stream[T_Item]`.
24
+
25
+ :param max_buffer_size: number of items held in the buffer until ``send()`` starts
26
+ blocking
27
+ :param item_type: old way of marking the streams with the right generic type for
28
+ static typing (does nothing on AnyIO 4)
29
+
30
+ .. deprecated:: 4.0
31
+ Use ``create_memory_object_stream[YourItemType](...)`` instead.
32
+ :return: a tuple of (send stream, receive stream)
33
+
34
+ """
35
+
36
+ def __new__( # type: ignore[misc]
37
+ cls, max_buffer_size: float = 0, item_type: object = None
38
+ ) -> tuple[MemoryObjectSendStream[T_Item], MemoryObjectReceiveStream[T_Item]]:
39
+ if max_buffer_size != math.inf and not isinstance(max_buffer_size, int):
40
+ raise ValueError("max_buffer_size must be either an integer or math.inf")
41
+ if max_buffer_size < 0:
42
+ raise ValueError("max_buffer_size cannot be negative")
43
+ if item_type is not None:
44
+ warn(
45
+ "The item_type argument has been deprecated in AnyIO 4.0. "
46
+ "Use create_memory_object_stream[YourItemType](...) instead.",
47
+ DeprecationWarning,
48
+ stacklevel=2,
49
+ )
50
+
51
+ state = MemoryObjectStreamState[T_Item](max_buffer_size)
52
+ return (MemoryObjectSendStream(state), MemoryObjectReceiveStream(state))
miniconda3/lib/python3.13/site-packages/anyio/_core/_subprocesses.py ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ from collections.abc import AsyncIterable, Iterable, Mapping, Sequence
5
+ from io import BytesIO
6
+ from os import PathLike
7
+ from subprocess import PIPE, CalledProcessError, CompletedProcess
8
+ from typing import IO, Any, Union, cast
9
+
10
+ from ..abc import Process
11
+ from ._eventloop import get_async_backend
12
+ from ._tasks import create_task_group
13
+
14
+ if sys.version_info >= (3, 10):
15
+ from typing import TypeAlias
16
+ else:
17
+ from typing_extensions import TypeAlias
18
+
19
+ StrOrBytesPath: TypeAlias = Union[str, bytes, "PathLike[str]", "PathLike[bytes]"]
20
+
21
+
22
+ async def run_process(
23
+ command: StrOrBytesPath | Sequence[StrOrBytesPath],
24
+ *,
25
+ input: bytes | None = None,
26
+ stdin: int | IO[Any] | None = None,
27
+ stdout: int | IO[Any] | None = PIPE,
28
+ stderr: int | IO[Any] | None = PIPE,
29
+ check: bool = True,
30
+ cwd: StrOrBytesPath | None = None,
31
+ env: Mapping[str, str] | None = None,
32
+ startupinfo: Any = None,
33
+ creationflags: int = 0,
34
+ start_new_session: bool = False,
35
+ pass_fds: Sequence[int] = (),
36
+ user: str | int | None = None,
37
+ group: str | int | None = None,
38
+ extra_groups: Iterable[str | int] | None = None,
39
+ umask: int = -1,
40
+ ) -> CompletedProcess[bytes]:
41
+ """
42
+ Run an external command in a subprocess and wait until it completes.
43
+
44
+ .. seealso:: :func:`subprocess.run`
45
+
46
+ :param command: either a string to pass to the shell, or an iterable of strings
47
+ containing the executable name or path and its arguments
48
+ :param input: bytes passed to the standard input of the subprocess
49
+ :param stdin: one of :data:`subprocess.PIPE`, :data:`subprocess.DEVNULL`,
50
+ a file-like object, or `None`; ``input`` overrides this
51
+ :param stdout: one of :data:`subprocess.PIPE`, :data:`subprocess.DEVNULL`,
52
+ a file-like object, or `None`
53
+ :param stderr: one of :data:`subprocess.PIPE`, :data:`subprocess.DEVNULL`,
54
+ :data:`subprocess.STDOUT`, a file-like object, or `None`
55
+ :param check: if ``True``, raise :exc:`~subprocess.CalledProcessError` if the
56
+ process terminates with a return code other than 0
57
+ :param cwd: If not ``None``, change the working directory to this before running the
58
+ command
59
+ :param env: if not ``None``, this mapping replaces the inherited environment
60
+ variables from the parent process
61
+ :param startupinfo: an instance of :class:`subprocess.STARTUPINFO` that can be used
62
+ to specify process startup parameters (Windows only)
63
+ :param creationflags: flags that can be used to control the creation of the
64
+ subprocess (see :class:`subprocess.Popen` for the specifics)
65
+ :param start_new_session: if ``true`` the setsid() system call will be made in the
66
+ child process prior to the execution of the subprocess. (POSIX only)
67
+ :param pass_fds: sequence of file descriptors to keep open between the parent and
68
+ child processes. (POSIX only)
69
+ :param user: effective user to run the process as (Python >= 3.9, POSIX only)
70
+ :param group: effective group to run the process as (Python >= 3.9, POSIX only)
71
+ :param extra_groups: supplementary groups to set in the subprocess (Python >= 3.9,
72
+ POSIX only)
73
+ :param umask: if not negative, this umask is applied in the child process before
74
+ running the given command (Python >= 3.9, POSIX only)
75
+ :return: an object representing the completed process
76
+ :raises ~subprocess.CalledProcessError: if ``check`` is ``True`` and the process
77
+ exits with a nonzero return code
78
+
79
+ """
80
+
81
+ async def drain_stream(stream: AsyncIterable[bytes], index: int) -> None:
82
+ buffer = BytesIO()
83
+ async for chunk in stream:
84
+ buffer.write(chunk)
85
+
86
+ stream_contents[index] = buffer.getvalue()
87
+
88
+ if stdin is not None and input is not None:
89
+ raise ValueError("only one of stdin and input is allowed")
90
+
91
+ async with await open_process(
92
+ command,
93
+ stdin=PIPE if input else stdin,
94
+ stdout=stdout,
95
+ stderr=stderr,
96
+ cwd=cwd,
97
+ env=env,
98
+ startupinfo=startupinfo,
99
+ creationflags=creationflags,
100
+ start_new_session=start_new_session,
101
+ pass_fds=pass_fds,
102
+ user=user,
103
+ group=group,
104
+ extra_groups=extra_groups,
105
+ umask=umask,
106
+ ) as process:
107
+ stream_contents: list[bytes | None] = [None, None]
108
+ async with create_task_group() as tg:
109
+ if process.stdout:
110
+ tg.start_soon(drain_stream, process.stdout, 0)
111
+
112
+ if process.stderr:
113
+ tg.start_soon(drain_stream, process.stderr, 1)
114
+
115
+ if process.stdin and input:
116
+ await process.stdin.send(input)
117
+ await process.stdin.aclose()
118
+
119
+ await process.wait()
120
+
121
+ output, errors = stream_contents
122
+ if check and process.returncode != 0:
123
+ raise CalledProcessError(cast(int, process.returncode), command, output, errors)
124
+
125
+ return CompletedProcess(command, cast(int, process.returncode), output, errors)
126
+
127
+
128
+ async def open_process(
129
+ command: StrOrBytesPath | Sequence[StrOrBytesPath],
130
+ *,
131
+ stdin: int | IO[Any] | None = PIPE,
132
+ stdout: int | IO[Any] | None = PIPE,
133
+ stderr: int | IO[Any] | None = PIPE,
134
+ cwd: StrOrBytesPath | None = None,
135
+ env: Mapping[str, str] | None = None,
136
+ startupinfo: Any = None,
137
+ creationflags: int = 0,
138
+ start_new_session: bool = False,
139
+ pass_fds: Sequence[int] = (),
140
+ user: str | int | None = None,
141
+ group: str | int | None = None,
142
+ extra_groups: Iterable[str | int] | None = None,
143
+ umask: int = -1,
144
+ ) -> Process:
145
+ """
146
+ Start an external command in a subprocess.
147
+
148
+ .. seealso:: :class:`subprocess.Popen`
149
+
150
+ :param command: either a string to pass to the shell, or an iterable of strings
151
+ containing the executable name or path and its arguments
152
+ :param stdin: one of :data:`subprocess.PIPE`, :data:`subprocess.DEVNULL`, a
153
+ file-like object, or ``None``
154
+ :param stdout: one of :data:`subprocess.PIPE`, :data:`subprocess.DEVNULL`,
155
+ a file-like object, or ``None``
156
+ :param stderr: one of :data:`subprocess.PIPE`, :data:`subprocess.DEVNULL`,
157
+ :data:`subprocess.STDOUT`, a file-like object, or ``None``
158
+ :param cwd: If not ``None``, the working directory is changed before executing
159
+ :param env: If env is not ``None``, it must be a mapping that defines the
160
+ environment variables for the new process
161
+ :param creationflags: flags that can be used to control the creation of the
162
+ subprocess (see :class:`subprocess.Popen` for the specifics)
163
+ :param startupinfo: an instance of :class:`subprocess.STARTUPINFO` that can be used
164
+ to specify process startup parameters (Windows only)
165
+ :param start_new_session: if ``true`` the setsid() system call will be made in the
166
+ child process prior to the execution of the subprocess. (POSIX only)
167
+ :param pass_fds: sequence of file descriptors to keep open between the parent and
168
+ child processes. (POSIX only)
169
+ :param user: effective user to run the process as (POSIX only)
170
+ :param group: effective group to run the process as (POSIX only)
171
+ :param extra_groups: supplementary groups to set in the subprocess (POSIX only)
172
+ :param umask: if not negative, this umask is applied in the child process before
173
+ running the given command (POSIX only)
174
+ :return: an asynchronous process object
175
+
176
+ """
177
+ kwargs: dict[str, Any] = {}
178
+ if user is not None:
179
+ kwargs["user"] = user
180
+
181
+ if group is not None:
182
+ kwargs["group"] = group
183
+
184
+ if extra_groups is not None:
185
+ kwargs["extra_groups"] = group
186
+
187
+ if umask >= 0:
188
+ kwargs["umask"] = umask
189
+
190
+ return await get_async_backend().open_process(
191
+ command,
192
+ stdin=stdin,
193
+ stdout=stdout,
194
+ stderr=stderr,
195
+ cwd=cwd,
196
+ env=env,
197
+ startupinfo=startupinfo,
198
+ creationflags=creationflags,
199
+ start_new_session=start_new_session,
200
+ pass_fds=pass_fds,
201
+ **kwargs,
202
+ )
miniconda3/lib/python3.13/site-packages/anyio/_core/_synchronization.py ADDED
@@ -0,0 +1,732 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import math
4
+ from collections import deque
5
+ from dataclasses import dataclass
6
+ from types import TracebackType
7
+
8
+ from sniffio import AsyncLibraryNotFoundError
9
+
10
+ from ..lowlevel import checkpoint
11
+ from ._eventloop import get_async_backend
12
+ from ._exceptions import BusyResourceError
13
+ from ._tasks import CancelScope
14
+ from ._testing import TaskInfo, get_current_task
15
+
16
+
17
+ @dataclass(frozen=True)
18
+ class EventStatistics:
19
+ """
20
+ :ivar int tasks_waiting: number of tasks waiting on :meth:`~.Event.wait`
21
+ """
22
+
23
+ tasks_waiting: int
24
+
25
+
26
+ @dataclass(frozen=True)
27
+ class CapacityLimiterStatistics:
28
+ """
29
+ :ivar int borrowed_tokens: number of tokens currently borrowed by tasks
30
+ :ivar float total_tokens: total number of available tokens
31
+ :ivar tuple borrowers: tasks or other objects currently holding tokens borrowed from
32
+ this limiter
33
+ :ivar int tasks_waiting: number of tasks waiting on
34
+ :meth:`~.CapacityLimiter.acquire` or
35
+ :meth:`~.CapacityLimiter.acquire_on_behalf_of`
36
+ """
37
+
38
+ borrowed_tokens: int
39
+ total_tokens: float
40
+ borrowers: tuple[object, ...]
41
+ tasks_waiting: int
42
+
43
+
44
+ @dataclass(frozen=True)
45
+ class LockStatistics:
46
+ """
47
+ :ivar bool locked: flag indicating if this lock is locked or not
48
+ :ivar ~anyio.TaskInfo owner: task currently holding the lock (or ``None`` if the
49
+ lock is not held by any task)
50
+ :ivar int tasks_waiting: number of tasks waiting on :meth:`~.Lock.acquire`
51
+ """
52
+
53
+ locked: bool
54
+ owner: TaskInfo | None
55
+ tasks_waiting: int
56
+
57
+
58
+ @dataclass(frozen=True)
59
+ class ConditionStatistics:
60
+ """
61
+ :ivar int tasks_waiting: number of tasks blocked on :meth:`~.Condition.wait`
62
+ :ivar ~anyio.LockStatistics lock_statistics: statistics of the underlying
63
+ :class:`~.Lock`
64
+ """
65
+
66
+ tasks_waiting: int
67
+ lock_statistics: LockStatistics
68
+
69
+
70
+ @dataclass(frozen=True)
71
+ class SemaphoreStatistics:
72
+ """
73
+ :ivar int tasks_waiting: number of tasks waiting on :meth:`~.Semaphore.acquire`
74
+
75
+ """
76
+
77
+ tasks_waiting: int
78
+
79
+
80
+ class Event:
81
+ def __new__(cls) -> Event:
82
+ try:
83
+ return get_async_backend().create_event()
84
+ except AsyncLibraryNotFoundError:
85
+ return EventAdapter()
86
+
87
+ def set(self) -> None:
88
+ """Set the flag, notifying all listeners."""
89
+ raise NotImplementedError
90
+
91
+ def is_set(self) -> bool:
92
+ """Return ``True`` if the flag is set, ``False`` if not."""
93
+ raise NotImplementedError
94
+
95
+ async def wait(self) -> None:
96
+ """
97
+ Wait until the flag has been set.
98
+
99
+ If the flag has already been set when this method is called, it returns
100
+ immediately.
101
+
102
+ """
103
+ raise NotImplementedError
104
+
105
+ def statistics(self) -> EventStatistics:
106
+ """Return statistics about the current state of this event."""
107
+ raise NotImplementedError
108
+
109
+
110
+ class EventAdapter(Event):
111
+ _internal_event: Event | None = None
112
+ _is_set: bool = False
113
+
114
+ def __new__(cls) -> EventAdapter:
115
+ return object.__new__(cls)
116
+
117
+ @property
118
+ def _event(self) -> Event:
119
+ if self._internal_event is None:
120
+ self._internal_event = get_async_backend().create_event()
121
+ if self._is_set:
122
+ self._internal_event.set()
123
+
124
+ return self._internal_event
125
+
126
+ def set(self) -> None:
127
+ if self._internal_event is None:
128
+ self._is_set = True
129
+ else:
130
+ self._event.set()
131
+
132
+ def is_set(self) -> bool:
133
+ if self._internal_event is None:
134
+ return self._is_set
135
+
136
+ return self._internal_event.is_set()
137
+
138
+ async def wait(self) -> None:
139
+ await self._event.wait()
140
+
141
+ def statistics(self) -> EventStatistics:
142
+ if self._internal_event is None:
143
+ return EventStatistics(tasks_waiting=0)
144
+
145
+ return self._internal_event.statistics()
146
+
147
+
148
+ class Lock:
149
+ def __new__(cls, *, fast_acquire: bool = False) -> Lock:
150
+ try:
151
+ return get_async_backend().create_lock(fast_acquire=fast_acquire)
152
+ except AsyncLibraryNotFoundError:
153
+ return LockAdapter(fast_acquire=fast_acquire)
154
+
155
+ async def __aenter__(self) -> None:
156
+ await self.acquire()
157
+
158
+ async def __aexit__(
159
+ self,
160
+ exc_type: type[BaseException] | None,
161
+ exc_val: BaseException | None,
162
+ exc_tb: TracebackType | None,
163
+ ) -> None:
164
+ self.release()
165
+
166
+ async def acquire(self) -> None:
167
+ """Acquire the lock."""
168
+ raise NotImplementedError
169
+
170
+ def acquire_nowait(self) -> None:
171
+ """
172
+ Acquire the lock, without blocking.
173
+
174
+ :raises ~anyio.WouldBlock: if the operation would block
175
+
176
+ """
177
+ raise NotImplementedError
178
+
179
+ def release(self) -> None:
180
+ """Release the lock."""
181
+ raise NotImplementedError
182
+
183
+ def locked(self) -> bool:
184
+ """Return True if the lock is currently held."""
185
+ raise NotImplementedError
186
+
187
+ def statistics(self) -> LockStatistics:
188
+ """
189
+ Return statistics about the current state of this lock.
190
+
191
+ .. versionadded:: 3.0
192
+ """
193
+ raise NotImplementedError
194
+
195
+
196
+ class LockAdapter(Lock):
197
+ _internal_lock: Lock | None = None
198
+
199
+ def __new__(cls, *, fast_acquire: bool = False) -> LockAdapter:
200
+ return object.__new__(cls)
201
+
202
+ def __init__(self, *, fast_acquire: bool = False):
203
+ self._fast_acquire = fast_acquire
204
+
205
+ @property
206
+ def _lock(self) -> Lock:
207
+ if self._internal_lock is None:
208
+ self._internal_lock = get_async_backend().create_lock(
209
+ fast_acquire=self._fast_acquire
210
+ )
211
+
212
+ return self._internal_lock
213
+
214
+ async def __aenter__(self) -> None:
215
+ await self._lock.acquire()
216
+
217
+ async def __aexit__(
218
+ self,
219
+ exc_type: type[BaseException] | None,
220
+ exc_val: BaseException | None,
221
+ exc_tb: TracebackType | None,
222
+ ) -> None:
223
+ if self._internal_lock is not None:
224
+ self._internal_lock.release()
225
+
226
+ async def acquire(self) -> None:
227
+ """Acquire the lock."""
228
+ await self._lock.acquire()
229
+
230
+ def acquire_nowait(self) -> None:
231
+ """
232
+ Acquire the lock, without blocking.
233
+
234
+ :raises ~anyio.WouldBlock: if the operation would block
235
+
236
+ """
237
+ self._lock.acquire_nowait()
238
+
239
+ def release(self) -> None:
240
+ """Release the lock."""
241
+ self._lock.release()
242
+
243
+ def locked(self) -> bool:
244
+ """Return True if the lock is currently held."""
245
+ return self._lock.locked()
246
+
247
+ def statistics(self) -> LockStatistics:
248
+ """
249
+ Return statistics about the current state of this lock.
250
+
251
+ .. versionadded:: 3.0
252
+
253
+ """
254
+ if self._internal_lock is None:
255
+ return LockStatistics(False, None, 0)
256
+
257
+ return self._internal_lock.statistics()
258
+
259
+
260
+ class Condition:
261
+ _owner_task: TaskInfo | None = None
262
+
263
+ def __init__(self, lock: Lock | None = None):
264
+ self._lock = lock or Lock()
265
+ self._waiters: deque[Event] = deque()
266
+
267
+ async def __aenter__(self) -> None:
268
+ await self.acquire()
269
+
270
+ async def __aexit__(
271
+ self,
272
+ exc_type: type[BaseException] | None,
273
+ exc_val: BaseException | None,
274
+ exc_tb: TracebackType | None,
275
+ ) -> None:
276
+ self.release()
277
+
278
+ def _check_acquired(self) -> None:
279
+ if self._owner_task != get_current_task():
280
+ raise RuntimeError("The current task is not holding the underlying lock")
281
+
282
+ async def acquire(self) -> None:
283
+ """Acquire the underlying lock."""
284
+ await self._lock.acquire()
285
+ self._owner_task = get_current_task()
286
+
287
+ def acquire_nowait(self) -> None:
288
+ """
289
+ Acquire the underlying lock, without blocking.
290
+
291
+ :raises ~anyio.WouldBlock: if the operation would block
292
+
293
+ """
294
+ self._lock.acquire_nowait()
295
+ self._owner_task = get_current_task()
296
+
297
+ def release(self) -> None:
298
+ """Release the underlying lock."""
299
+ self._lock.release()
300
+
301
+ def locked(self) -> bool:
302
+ """Return True if the lock is set."""
303
+ return self._lock.locked()
304
+
305
+ def notify(self, n: int = 1) -> None:
306
+ """Notify exactly n listeners."""
307
+ self._check_acquired()
308
+ for _ in range(n):
309
+ try:
310
+ event = self._waiters.popleft()
311
+ except IndexError:
312
+ break
313
+
314
+ event.set()
315
+
316
+ def notify_all(self) -> None:
317
+ """Notify all the listeners."""
318
+ self._check_acquired()
319
+ for event in self._waiters:
320
+ event.set()
321
+
322
+ self._waiters.clear()
323
+
324
+ async def wait(self) -> None:
325
+ """Wait for a notification."""
326
+ await checkpoint()
327
+ event = Event()
328
+ self._waiters.append(event)
329
+ self.release()
330
+ try:
331
+ await event.wait()
332
+ except BaseException:
333
+ if not event.is_set():
334
+ self._waiters.remove(event)
335
+
336
+ raise
337
+ finally:
338
+ with CancelScope(shield=True):
339
+ await self.acquire()
340
+
341
+ def statistics(self) -> ConditionStatistics:
342
+ """
343
+ Return statistics about the current state of this condition.
344
+
345
+ .. versionadded:: 3.0
346
+ """
347
+ return ConditionStatistics(len(self._waiters), self._lock.statistics())
348
+
349
+
350
+ class Semaphore:
351
+ def __new__(
352
+ cls,
353
+ initial_value: int,
354
+ *,
355
+ max_value: int | None = None,
356
+ fast_acquire: bool = False,
357
+ ) -> Semaphore:
358
+ try:
359
+ return get_async_backend().create_semaphore(
360
+ initial_value, max_value=max_value, fast_acquire=fast_acquire
361
+ )
362
+ except AsyncLibraryNotFoundError:
363
+ return SemaphoreAdapter(initial_value, max_value=max_value)
364
+
365
+ def __init__(
366
+ self,
367
+ initial_value: int,
368
+ *,
369
+ max_value: int | None = None,
370
+ fast_acquire: bool = False,
371
+ ):
372
+ if not isinstance(initial_value, int):
373
+ raise TypeError("initial_value must be an integer")
374
+ if initial_value < 0:
375
+ raise ValueError("initial_value must be >= 0")
376
+ if max_value is not None:
377
+ if not isinstance(max_value, int):
378
+ raise TypeError("max_value must be an integer or None")
379
+ if max_value < initial_value:
380
+ raise ValueError(
381
+ "max_value must be equal to or higher than initial_value"
382
+ )
383
+
384
+ self._fast_acquire = fast_acquire
385
+
386
+ async def __aenter__(self) -> Semaphore:
387
+ await self.acquire()
388
+ return self
389
+
390
+ async def __aexit__(
391
+ self,
392
+ exc_type: type[BaseException] | None,
393
+ exc_val: BaseException | None,
394
+ exc_tb: TracebackType | None,
395
+ ) -> None:
396
+ self.release()
397
+
398
+ async def acquire(self) -> None:
399
+ """Decrement the semaphore value, blocking if necessary."""
400
+ raise NotImplementedError
401
+
402
+ def acquire_nowait(self) -> None:
403
+ """
404
+ Acquire the underlying lock, without blocking.
405
+
406
+ :raises ~anyio.WouldBlock: if the operation would block
407
+
408
+ """
409
+ raise NotImplementedError
410
+
411
+ def release(self) -> None:
412
+ """Increment the semaphore value."""
413
+ raise NotImplementedError
414
+
415
+ @property
416
+ def value(self) -> int:
417
+ """The current value of the semaphore."""
418
+ raise NotImplementedError
419
+
420
+ @property
421
+ def max_value(self) -> int | None:
422
+ """The maximum value of the semaphore."""
423
+ raise NotImplementedError
424
+
425
+ def statistics(self) -> SemaphoreStatistics:
426
+ """
427
+ Return statistics about the current state of this semaphore.
428
+
429
+ .. versionadded:: 3.0
430
+ """
431
+ raise NotImplementedError
432
+
433
+
434
+ class SemaphoreAdapter(Semaphore):
435
+ _internal_semaphore: Semaphore | None = None
436
+
437
+ def __new__(
438
+ cls,
439
+ initial_value: int,
440
+ *,
441
+ max_value: int | None = None,
442
+ fast_acquire: bool = False,
443
+ ) -> SemaphoreAdapter:
444
+ return object.__new__(cls)
445
+
446
+ def __init__(
447
+ self,
448
+ initial_value: int,
449
+ *,
450
+ max_value: int | None = None,
451
+ fast_acquire: bool = False,
452
+ ) -> None:
453
+ super().__init__(initial_value, max_value=max_value, fast_acquire=fast_acquire)
454
+ self._initial_value = initial_value
455
+ self._max_value = max_value
456
+
457
+ @property
458
+ def _semaphore(self) -> Semaphore:
459
+ if self._internal_semaphore is None:
460
+ self._internal_semaphore = get_async_backend().create_semaphore(
461
+ self._initial_value, max_value=self._max_value
462
+ )
463
+
464
+ return self._internal_semaphore
465
+
466
+ async def acquire(self) -> None:
467
+ await self._semaphore.acquire()
468
+
469
+ def acquire_nowait(self) -> None:
470
+ self._semaphore.acquire_nowait()
471
+
472
+ def release(self) -> None:
473
+ self._semaphore.release()
474
+
475
+ @property
476
+ def value(self) -> int:
477
+ if self._internal_semaphore is None:
478
+ return self._initial_value
479
+
480
+ return self._semaphore.value
481
+
482
+ @property
483
+ def max_value(self) -> int | None:
484
+ return self._max_value
485
+
486
+ def statistics(self) -> SemaphoreStatistics:
487
+ if self._internal_semaphore is None:
488
+ return SemaphoreStatistics(tasks_waiting=0)
489
+
490
+ return self._semaphore.statistics()
491
+
492
+
493
+ class CapacityLimiter:
494
+ def __new__(cls, total_tokens: float) -> CapacityLimiter:
495
+ try:
496
+ return get_async_backend().create_capacity_limiter(total_tokens)
497
+ except AsyncLibraryNotFoundError:
498
+ return CapacityLimiterAdapter(total_tokens)
499
+
500
+ async def __aenter__(self) -> None:
501
+ raise NotImplementedError
502
+
503
+ async def __aexit__(
504
+ self,
505
+ exc_type: type[BaseException] | None,
506
+ exc_val: BaseException | None,
507
+ exc_tb: TracebackType | None,
508
+ ) -> None:
509
+ raise NotImplementedError
510
+
511
+ @property
512
+ def total_tokens(self) -> float:
513
+ """
514
+ The total number of tokens available for borrowing.
515
+
516
+ This is a read-write property. If the total number of tokens is increased, the
517
+ proportionate number of tasks waiting on this limiter will be granted their
518
+ tokens.
519
+
520
+ .. versionchanged:: 3.0
521
+ The property is now writable.
522
+
523
+ """
524
+ raise NotImplementedError
525
+
526
+ @total_tokens.setter
527
+ def total_tokens(self, value: float) -> None:
528
+ raise NotImplementedError
529
+
530
+ @property
531
+ def borrowed_tokens(self) -> int:
532
+ """The number of tokens that have currently been borrowed."""
533
+ raise NotImplementedError
534
+
535
+ @property
536
+ def available_tokens(self) -> float:
537
+ """The number of tokens currently available to be borrowed"""
538
+ raise NotImplementedError
539
+
540
+ def acquire_nowait(self) -> None:
541
+ """
542
+ Acquire a token for the current task without waiting for one to become
543
+ available.
544
+
545
+ :raises ~anyio.WouldBlock: if there are no tokens available for borrowing
546
+
547
+ """
548
+ raise NotImplementedError
549
+
550
+ def acquire_on_behalf_of_nowait(self, borrower: object) -> None:
551
+ """
552
+ Acquire a token without waiting for one to become available.
553
+
554
+ :param borrower: the entity borrowing a token
555
+ :raises ~anyio.WouldBlock: if there are no tokens available for borrowing
556
+
557
+ """
558
+ raise NotImplementedError
559
+
560
+ async def acquire(self) -> None:
561
+ """
562
+ Acquire a token for the current task, waiting if necessary for one to become
563
+ available.
564
+
565
+ """
566
+ raise NotImplementedError
567
+
568
+ async def acquire_on_behalf_of(self, borrower: object) -> None:
569
+ """
570
+ Acquire a token, waiting if necessary for one to become available.
571
+
572
+ :param borrower: the entity borrowing a token
573
+
574
+ """
575
+ raise NotImplementedError
576
+
577
+ def release(self) -> None:
578
+ """
579
+ Release the token held by the current task.
580
+
581
+ :raises RuntimeError: if the current task has not borrowed a token from this
582
+ limiter.
583
+
584
+ """
585
+ raise NotImplementedError
586
+
587
+ def release_on_behalf_of(self, borrower: object) -> None:
588
+ """
589
+ Release the token held by the given borrower.
590
+
591
+ :raises RuntimeError: if the borrower has not borrowed a token from this
592
+ limiter.
593
+
594
+ """
595
+ raise NotImplementedError
596
+
597
+ def statistics(self) -> CapacityLimiterStatistics:
598
+ """
599
+ Return statistics about the current state of this limiter.
600
+
601
+ .. versionadded:: 3.0
602
+
603
+ """
604
+ raise NotImplementedError
605
+
606
+
607
+ class CapacityLimiterAdapter(CapacityLimiter):
608
+ _internal_limiter: CapacityLimiter | None = None
609
+
610
+ def __new__(cls, total_tokens: float) -> CapacityLimiterAdapter:
611
+ return object.__new__(cls)
612
+
613
+ def __init__(self, total_tokens: float) -> None:
614
+ self.total_tokens = total_tokens
615
+
616
+ @property
617
+ def _limiter(self) -> CapacityLimiter:
618
+ if self._internal_limiter is None:
619
+ self._internal_limiter = get_async_backend().create_capacity_limiter(
620
+ self._total_tokens
621
+ )
622
+
623
+ return self._internal_limiter
624
+
625
+ async def __aenter__(self) -> None:
626
+ await self._limiter.__aenter__()
627
+
628
+ async def __aexit__(
629
+ self,
630
+ exc_type: type[BaseException] | None,
631
+ exc_val: BaseException | None,
632
+ exc_tb: TracebackType | None,
633
+ ) -> None:
634
+ return await self._limiter.__aexit__(exc_type, exc_val, exc_tb)
635
+
636
+ @property
637
+ def total_tokens(self) -> float:
638
+ if self._internal_limiter is None:
639
+ return self._total_tokens
640
+
641
+ return self._internal_limiter.total_tokens
642
+
643
+ @total_tokens.setter
644
+ def total_tokens(self, value: float) -> None:
645
+ if not isinstance(value, int) and value is not math.inf:
646
+ raise TypeError("total_tokens must be an int or math.inf")
647
+ elif value < 1:
648
+ raise ValueError("total_tokens must be >= 1")
649
+
650
+ if self._internal_limiter is None:
651
+ self._total_tokens = value
652
+ return
653
+
654
+ self._limiter.total_tokens = value
655
+
656
+ @property
657
+ def borrowed_tokens(self) -> int:
658
+ if self._internal_limiter is None:
659
+ return 0
660
+
661
+ return self._internal_limiter.borrowed_tokens
662
+
663
+ @property
664
+ def available_tokens(self) -> float:
665
+ if self._internal_limiter is None:
666
+ return self._total_tokens
667
+
668
+ return self._internal_limiter.available_tokens
669
+
670
+ def acquire_nowait(self) -> None:
671
+ self._limiter.acquire_nowait()
672
+
673
+ def acquire_on_behalf_of_nowait(self, borrower: object) -> None:
674
+ self._limiter.acquire_on_behalf_of_nowait(borrower)
675
+
676
+ async def acquire(self) -> None:
677
+ await self._limiter.acquire()
678
+
679
+ async def acquire_on_behalf_of(self, borrower: object) -> None:
680
+ await self._limiter.acquire_on_behalf_of(borrower)
681
+
682
+ def release(self) -> None:
683
+ self._limiter.release()
684
+
685
+ def release_on_behalf_of(self, borrower: object) -> None:
686
+ self._limiter.release_on_behalf_of(borrower)
687
+
688
+ def statistics(self) -> CapacityLimiterStatistics:
689
+ if self._internal_limiter is None:
690
+ return CapacityLimiterStatistics(
691
+ borrowed_tokens=0,
692
+ total_tokens=self.total_tokens,
693
+ borrowers=(),
694
+ tasks_waiting=0,
695
+ )
696
+
697
+ return self._internal_limiter.statistics()
698
+
699
+
700
+ class ResourceGuard:
701
+ """
702
+ A context manager for ensuring that a resource is only used by a single task at a
703
+ time.
704
+
705
+ Entering this context manager while the previous has not exited it yet will trigger
706
+ :exc:`BusyResourceError`.
707
+
708
+ :param action: the action to guard against (visible in the :exc:`BusyResourceError`
709
+ when triggered, e.g. "Another task is already {action} this resource")
710
+
711
+ .. versionadded:: 4.1
712
+ """
713
+
714
+ __slots__ = "action", "_guarded"
715
+
716
+ def __init__(self, action: str = "using"):
717
+ self.action: str = action
718
+ self._guarded = False
719
+
720
+ def __enter__(self) -> None:
721
+ if self._guarded:
722
+ raise BusyResourceError(self.action)
723
+
724
+ self._guarded = True
725
+
726
+ def __exit__(
727
+ self,
728
+ exc_type: type[BaseException] | None,
729
+ exc_val: BaseException | None,
730
+ exc_tb: TracebackType | None,
731
+ ) -> None:
732
+ self._guarded = False
miniconda3/lib/python3.13/site-packages/anyio/_core/_tasks.py ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import math
4
+ from collections.abc import Generator
5
+ from contextlib import contextmanager
6
+ from types import TracebackType
7
+
8
+ from ..abc._tasks import TaskGroup, TaskStatus
9
+ from ._eventloop import get_async_backend
10
+
11
+
12
+ class _IgnoredTaskStatus(TaskStatus[object]):
13
+ def started(self, value: object = None) -> None:
14
+ pass
15
+
16
+
17
+ TASK_STATUS_IGNORED = _IgnoredTaskStatus()
18
+
19
+
20
+ class CancelScope:
21
+ """
22
+ Wraps a unit of work that can be made separately cancellable.
23
+
24
+ :param deadline: The time (clock value) when this scope is cancelled automatically
25
+ :param shield: ``True`` to shield the cancel scope from external cancellation
26
+ """
27
+
28
+ def __new__(
29
+ cls, *, deadline: float = math.inf, shield: bool = False
30
+ ) -> CancelScope:
31
+ return get_async_backend().create_cancel_scope(shield=shield, deadline=deadline)
32
+
33
+ def cancel(self) -> None:
34
+ """Cancel this scope immediately."""
35
+ raise NotImplementedError
36
+
37
+ @property
38
+ def deadline(self) -> float:
39
+ """
40
+ The time (clock value) when this scope is cancelled automatically.
41
+
42
+ Will be ``float('inf')`` if no timeout has been set.
43
+
44
+ """
45
+ raise NotImplementedError
46
+
47
+ @deadline.setter
48
+ def deadline(self, value: float) -> None:
49
+ raise NotImplementedError
50
+
51
+ @property
52
+ def cancel_called(self) -> bool:
53
+ """``True`` if :meth:`cancel` has been called."""
54
+ raise NotImplementedError
55
+
56
+ @property
57
+ def cancelled_caught(self) -> bool:
58
+ """
59
+ ``True`` if this scope suppressed a cancellation exception it itself raised.
60
+
61
+ This is typically used to check if any work was interrupted, or to see if the
62
+ scope was cancelled due to its deadline being reached. The value will, however,
63
+ only be ``True`` if the cancellation was triggered by the scope itself (and not
64
+ an outer scope).
65
+
66
+ """
67
+ raise NotImplementedError
68
+
69
+ @property
70
+ def shield(self) -> bool:
71
+ """
72
+ ``True`` if this scope is shielded from external cancellation.
73
+
74
+ While a scope is shielded, it will not receive cancellations from outside.
75
+
76
+ """
77
+ raise NotImplementedError
78
+
79
+ @shield.setter
80
+ def shield(self, value: bool) -> None:
81
+ raise NotImplementedError
82
+
83
+ def __enter__(self) -> CancelScope:
84
+ raise NotImplementedError
85
+
86
+ def __exit__(
87
+ self,
88
+ exc_type: type[BaseException] | None,
89
+ exc_val: BaseException | None,
90
+ exc_tb: TracebackType | None,
91
+ ) -> bool:
92
+ raise NotImplementedError
93
+
94
+
95
+ @contextmanager
96
+ def fail_after(
97
+ delay: float | None, shield: bool = False
98
+ ) -> Generator[CancelScope, None, None]:
99
+ """
100
+ Create a context manager which raises a :class:`TimeoutError` if does not finish in
101
+ time.
102
+
103
+ :param delay: maximum allowed time (in seconds) before raising the exception, or
104
+ ``None`` to disable the timeout
105
+ :param shield: ``True`` to shield the cancel scope from external cancellation
106
+ :return: a context manager that yields a cancel scope
107
+ :rtype: :class:`~typing.ContextManager`\\[:class:`~anyio.CancelScope`\\]
108
+
109
+ """
110
+ current_time = get_async_backend().current_time
111
+ deadline = (current_time() + delay) if delay is not None else math.inf
112
+ with get_async_backend().create_cancel_scope(
113
+ deadline=deadline, shield=shield
114
+ ) as cancel_scope:
115
+ yield cancel_scope
116
+
117
+ if cancel_scope.cancelled_caught and current_time() >= cancel_scope.deadline:
118
+ raise TimeoutError
119
+
120
+
121
+ def move_on_after(delay: float | None, shield: bool = False) -> CancelScope:
122
+ """
123
+ Create a cancel scope with a deadline that expires after the given delay.
124
+
125
+ :param delay: maximum allowed time (in seconds) before exiting the context block, or
126
+ ``None`` to disable the timeout
127
+ :param shield: ``True`` to shield the cancel scope from external cancellation
128
+ :return: a cancel scope
129
+
130
+ """
131
+ deadline = (
132
+ (get_async_backend().current_time() + delay) if delay is not None else math.inf
133
+ )
134
+ return get_async_backend().create_cancel_scope(deadline=deadline, shield=shield)
135
+
136
+
137
+ def current_effective_deadline() -> float:
138
+ """
139
+ Return the nearest deadline among all the cancel scopes effective for the current
140
+ task.
141
+
142
+ :return: a clock value from the event loop's internal clock (or ``float('inf')`` if
143
+ there is no deadline in effect, or ``float('-inf')`` if the current scope has
144
+ been cancelled)
145
+ :rtype: float
146
+
147
+ """
148
+ return get_async_backend().current_effective_deadline()
149
+
150
+
151
+ def create_task_group() -> TaskGroup:
152
+ """
153
+ Create a task group.
154
+
155
+ :return: a task group
156
+
157
+ """
158
+ return get_async_backend().create_task_group()
miniconda3/lib/python3.13/site-packages/anyio/_core/_tempfile.py ADDED
@@ -0,0 +1,616 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import sys
5
+ import tempfile
6
+ from collections.abc import Iterable
7
+ from io import BytesIO, TextIOWrapper
8
+ from types import TracebackType
9
+ from typing import (
10
+ TYPE_CHECKING,
11
+ Any,
12
+ AnyStr,
13
+ Generic,
14
+ overload,
15
+ )
16
+
17
+ from .. import to_thread
18
+ from .._core._fileio import AsyncFile
19
+ from ..lowlevel import checkpoint_if_cancelled
20
+
21
+ if TYPE_CHECKING:
22
+ from _typeshed import OpenBinaryMode, OpenTextMode, ReadableBuffer, WriteableBuffer
23
+
24
+
25
+ class TemporaryFile(Generic[AnyStr]):
26
+ """
27
+ An asynchronous temporary file that is automatically created and cleaned up.
28
+
29
+ This class provides an asynchronous context manager interface to a temporary file.
30
+ The file is created using Python's standard `tempfile.TemporaryFile` function in a
31
+ background thread, and is wrapped as an asynchronous file using `AsyncFile`.
32
+
33
+ :param mode: The mode in which the file is opened. Defaults to "w+b".
34
+ :param buffering: The buffering policy (-1 means the default buffering).
35
+ :param encoding: The encoding used to decode or encode the file. Only applicable in
36
+ text mode.
37
+ :param newline: Controls how universal newlines mode works (only applicable in text
38
+ mode).
39
+ :param suffix: The suffix for the temporary file name.
40
+ :param prefix: The prefix for the temporary file name.
41
+ :param dir: The directory in which the temporary file is created.
42
+ :param errors: The error handling scheme used for encoding/decoding errors.
43
+ """
44
+
45
+ _async_file: AsyncFile[AnyStr]
46
+
47
+ @overload
48
+ def __init__(
49
+ self: TemporaryFile[bytes],
50
+ mode: OpenBinaryMode = ...,
51
+ buffering: int = ...,
52
+ encoding: str | None = ...,
53
+ newline: str | None = ...,
54
+ suffix: str | None = ...,
55
+ prefix: str | None = ...,
56
+ dir: str | None = ...,
57
+ *,
58
+ errors: str | None = ...,
59
+ ): ...
60
+ @overload
61
+ def __init__(
62
+ self: TemporaryFile[str],
63
+ mode: OpenTextMode,
64
+ buffering: int = ...,
65
+ encoding: str | None = ...,
66
+ newline: str | None = ...,
67
+ suffix: str | None = ...,
68
+ prefix: str | None = ...,
69
+ dir: str | None = ...,
70
+ *,
71
+ errors: str | None = ...,
72
+ ): ...
73
+
74
+ def __init__(
75
+ self,
76
+ mode: OpenTextMode | OpenBinaryMode = "w+b",
77
+ buffering: int = -1,
78
+ encoding: str | None = None,
79
+ newline: str | None = None,
80
+ suffix: str | None = None,
81
+ prefix: str | None = None,
82
+ dir: str | None = None,
83
+ *,
84
+ errors: str | None = None,
85
+ ) -> None:
86
+ self.mode = mode
87
+ self.buffering = buffering
88
+ self.encoding = encoding
89
+ self.newline = newline
90
+ self.suffix: str | None = suffix
91
+ self.prefix: str | None = prefix
92
+ self.dir: str | None = dir
93
+ self.errors = errors
94
+
95
+ async def __aenter__(self) -> AsyncFile[AnyStr]:
96
+ fp = await to_thread.run_sync(
97
+ lambda: tempfile.TemporaryFile(
98
+ self.mode,
99
+ self.buffering,
100
+ self.encoding,
101
+ self.newline,
102
+ self.suffix,
103
+ self.prefix,
104
+ self.dir,
105
+ errors=self.errors,
106
+ )
107
+ )
108
+ self._async_file = AsyncFile(fp)
109
+ return self._async_file
110
+
111
+ async def __aexit__(
112
+ self,
113
+ exc_type: type[BaseException] | None,
114
+ exc_value: BaseException | None,
115
+ traceback: TracebackType | None,
116
+ ) -> None:
117
+ await self._async_file.aclose()
118
+
119
+
120
+ class NamedTemporaryFile(Generic[AnyStr]):
121
+ """
122
+ An asynchronous named temporary file that is automatically created and cleaned up.
123
+
124
+ This class provides an asynchronous context manager for a temporary file with a
125
+ visible name in the file system. It uses Python's standard
126
+ :func:`~tempfile.NamedTemporaryFile` function and wraps the file object with
127
+ :class:`AsyncFile` for asynchronous operations.
128
+
129
+ :param mode: The mode in which the file is opened. Defaults to "w+b".
130
+ :param buffering: The buffering policy (-1 means the default buffering).
131
+ :param encoding: The encoding used to decode or encode the file. Only applicable in
132
+ text mode.
133
+ :param newline: Controls how universal newlines mode works (only applicable in text
134
+ mode).
135
+ :param suffix: The suffix for the temporary file name.
136
+ :param prefix: The prefix for the temporary file name.
137
+ :param dir: The directory in which the temporary file is created.
138
+ :param delete: Whether to delete the file when it is closed.
139
+ :param errors: The error handling scheme used for encoding/decoding errors.
140
+ :param delete_on_close: (Python 3.12+) Whether to delete the file on close.
141
+ """
142
+
143
+ _async_file: AsyncFile[AnyStr]
144
+
145
+ @overload
146
+ def __init__(
147
+ self: NamedTemporaryFile[bytes],
148
+ mode: OpenBinaryMode = ...,
149
+ buffering: int = ...,
150
+ encoding: str | None = ...,
151
+ newline: str | None = ...,
152
+ suffix: str | None = ...,
153
+ prefix: str | None = ...,
154
+ dir: str | None = ...,
155
+ delete: bool = ...,
156
+ *,
157
+ errors: str | None = ...,
158
+ delete_on_close: bool = ...,
159
+ ): ...
160
+ @overload
161
+ def __init__(
162
+ self: NamedTemporaryFile[str],
163
+ mode: OpenTextMode,
164
+ buffering: int = ...,
165
+ encoding: str | None = ...,
166
+ newline: str | None = ...,
167
+ suffix: str | None = ...,
168
+ prefix: str | None = ...,
169
+ dir: str | None = ...,
170
+ delete: bool = ...,
171
+ *,
172
+ errors: str | None = ...,
173
+ delete_on_close: bool = ...,
174
+ ): ...
175
+
176
+ def __init__(
177
+ self,
178
+ mode: OpenBinaryMode | OpenTextMode = "w+b",
179
+ buffering: int = -1,
180
+ encoding: str | None = None,
181
+ newline: str | None = None,
182
+ suffix: str | None = None,
183
+ prefix: str | None = None,
184
+ dir: str | None = None,
185
+ delete: bool = True,
186
+ *,
187
+ errors: str | None = None,
188
+ delete_on_close: bool = True,
189
+ ) -> None:
190
+ self._params: dict[str, Any] = {
191
+ "mode": mode,
192
+ "buffering": buffering,
193
+ "encoding": encoding,
194
+ "newline": newline,
195
+ "suffix": suffix,
196
+ "prefix": prefix,
197
+ "dir": dir,
198
+ "delete": delete,
199
+ "errors": errors,
200
+ }
201
+ if sys.version_info >= (3, 12):
202
+ self._params["delete_on_close"] = delete_on_close
203
+
204
+ async def __aenter__(self) -> AsyncFile[AnyStr]:
205
+ fp = await to_thread.run_sync(
206
+ lambda: tempfile.NamedTemporaryFile(**self._params)
207
+ )
208
+ self._async_file = AsyncFile(fp)
209
+ return self._async_file
210
+
211
+ async def __aexit__(
212
+ self,
213
+ exc_type: type[BaseException] | None,
214
+ exc_value: BaseException | None,
215
+ traceback: TracebackType | None,
216
+ ) -> None:
217
+ await self._async_file.aclose()
218
+
219
+
220
+ class SpooledTemporaryFile(AsyncFile[AnyStr]):
221
+ """
222
+ An asynchronous spooled temporary file that starts in memory and is spooled to disk.
223
+
224
+ This class provides an asynchronous interface to a spooled temporary file, much like
225
+ Python's standard :class:`~tempfile.SpooledTemporaryFile`. It supports asynchronous
226
+ write operations and provides a method to force a rollover to disk.
227
+
228
+ :param max_size: Maximum size in bytes before the file is rolled over to disk.
229
+ :param mode: The mode in which the file is opened. Defaults to "w+b".
230
+ :param buffering: The buffering policy (-1 means the default buffering).
231
+ :param encoding: The encoding used to decode or encode the file (text mode only).
232
+ :param newline: Controls how universal newlines mode works (text mode only).
233
+ :param suffix: The suffix for the temporary file name.
234
+ :param prefix: The prefix for the temporary file name.
235
+ :param dir: The directory in which the temporary file is created.
236
+ :param errors: The error handling scheme used for encoding/decoding errors.
237
+ """
238
+
239
+ _rolled: bool = False
240
+
241
+ @overload
242
+ def __init__(
243
+ self: SpooledTemporaryFile[bytes],
244
+ max_size: int = ...,
245
+ mode: OpenBinaryMode = ...,
246
+ buffering: int = ...,
247
+ encoding: str | None = ...,
248
+ newline: str | None = ...,
249
+ suffix: str | None = ...,
250
+ prefix: str | None = ...,
251
+ dir: str | None = ...,
252
+ *,
253
+ errors: str | None = ...,
254
+ ): ...
255
+ @overload
256
+ def __init__(
257
+ self: SpooledTemporaryFile[str],
258
+ max_size: int = ...,
259
+ mode: OpenTextMode = ...,
260
+ buffering: int = ...,
261
+ encoding: str | None = ...,
262
+ newline: str | None = ...,
263
+ suffix: str | None = ...,
264
+ prefix: str | None = ...,
265
+ dir: str | None = ...,
266
+ *,
267
+ errors: str | None = ...,
268
+ ): ...
269
+
270
+ def __init__(
271
+ self,
272
+ max_size: int = 0,
273
+ mode: OpenBinaryMode | OpenTextMode = "w+b",
274
+ buffering: int = -1,
275
+ encoding: str | None = None,
276
+ newline: str | None = None,
277
+ suffix: str | None = None,
278
+ prefix: str | None = None,
279
+ dir: str | None = None,
280
+ *,
281
+ errors: str | None = None,
282
+ ) -> None:
283
+ self._tempfile_params: dict[str, Any] = {
284
+ "mode": mode,
285
+ "buffering": buffering,
286
+ "encoding": encoding,
287
+ "newline": newline,
288
+ "suffix": suffix,
289
+ "prefix": prefix,
290
+ "dir": dir,
291
+ "errors": errors,
292
+ }
293
+ self._max_size = max_size
294
+ if "b" in mode:
295
+ super().__init__(BytesIO()) # type: ignore[arg-type]
296
+ else:
297
+ super().__init__(
298
+ TextIOWrapper( # type: ignore[arg-type]
299
+ BytesIO(),
300
+ encoding=encoding,
301
+ errors=errors,
302
+ newline=newline,
303
+ write_through=True,
304
+ )
305
+ )
306
+
307
+ async def aclose(self) -> None:
308
+ if not self._rolled:
309
+ self._fp.close()
310
+ return
311
+
312
+ await super().aclose()
313
+
314
+ async def _check(self) -> None:
315
+ if self._rolled or self._fp.tell() <= self._max_size:
316
+ return
317
+
318
+ await self.rollover()
319
+
320
+ async def rollover(self) -> None:
321
+ if self._rolled:
322
+ return
323
+
324
+ self._rolled = True
325
+ buffer = self._fp
326
+ buffer.seek(0)
327
+ self._fp = await to_thread.run_sync(
328
+ lambda: tempfile.TemporaryFile(**self._tempfile_params)
329
+ )
330
+ await self.write(buffer.read())
331
+ buffer.close()
332
+
333
+ @property
334
+ def closed(self) -> bool:
335
+ return self._fp.closed
336
+
337
+ async def read(self, size: int = -1) -> AnyStr:
338
+ if not self._rolled:
339
+ await checkpoint_if_cancelled()
340
+ return self._fp.read(size)
341
+
342
+ return await super().read(size) # type: ignore[return-value]
343
+
344
+ async def read1(self: SpooledTemporaryFile[bytes], size: int = -1) -> bytes:
345
+ if not self._rolled:
346
+ await checkpoint_if_cancelled()
347
+ return self._fp.read1(size)
348
+
349
+ return await super().read1(size)
350
+
351
+ async def readline(self) -> AnyStr:
352
+ if not self._rolled:
353
+ await checkpoint_if_cancelled()
354
+ return self._fp.readline()
355
+
356
+ return await super().readline() # type: ignore[return-value]
357
+
358
+ async def readlines(self) -> list[AnyStr]:
359
+ if not self._rolled:
360
+ await checkpoint_if_cancelled()
361
+ return self._fp.readlines()
362
+
363
+ return await super().readlines() # type: ignore[return-value]
364
+
365
+ async def readinto(self: SpooledTemporaryFile[bytes], b: WriteableBuffer) -> int:
366
+ if not self._rolled:
367
+ await checkpoint_if_cancelled()
368
+ self._fp.readinto(b)
369
+
370
+ return await super().readinto(b)
371
+
372
+ async def readinto1(self: SpooledTemporaryFile[bytes], b: WriteableBuffer) -> int:
373
+ if not self._rolled:
374
+ await checkpoint_if_cancelled()
375
+ self._fp.readinto(b)
376
+
377
+ return await super().readinto1(b)
378
+
379
+ async def seek(self, offset: int, whence: int | None = os.SEEK_SET) -> int:
380
+ if not self._rolled:
381
+ await checkpoint_if_cancelled()
382
+ return self._fp.seek(offset, whence)
383
+
384
+ return await super().seek(offset, whence)
385
+
386
+ async def tell(self) -> int:
387
+ if not self._rolled:
388
+ await checkpoint_if_cancelled()
389
+ return self._fp.tell()
390
+
391
+ return await super().tell()
392
+
393
+ async def truncate(self, size: int | None = None) -> int:
394
+ if not self._rolled:
395
+ await checkpoint_if_cancelled()
396
+ return self._fp.truncate(size)
397
+
398
+ return await super().truncate(size)
399
+
400
+ @overload
401
+ async def write(self: SpooledTemporaryFile[bytes], b: ReadableBuffer) -> int: ...
402
+ @overload
403
+ async def write(self: SpooledTemporaryFile[str], b: str) -> int: ...
404
+
405
+ async def write(self, b: ReadableBuffer | str) -> int:
406
+ """
407
+ Asynchronously write data to the spooled temporary file.
408
+
409
+ If the file has not yet been rolled over, the data is written synchronously,
410
+ and a rollover is triggered if the size exceeds the maximum size.
411
+
412
+ :param s: The data to write.
413
+ :return: The number of bytes written.
414
+ :raises RuntimeError: If the underlying file is not initialized.
415
+
416
+ """
417
+ if not self._rolled:
418
+ await checkpoint_if_cancelled()
419
+ result = self._fp.write(b)
420
+ await self._check()
421
+ return result
422
+
423
+ return await super().write(b) # type: ignore[misc]
424
+
425
+ @overload
426
+ async def writelines(
427
+ self: SpooledTemporaryFile[bytes], lines: Iterable[ReadableBuffer]
428
+ ) -> None: ...
429
+ @overload
430
+ async def writelines(
431
+ self: SpooledTemporaryFile[str], lines: Iterable[str]
432
+ ) -> None: ...
433
+
434
+ async def writelines(self, lines: Iterable[str] | Iterable[ReadableBuffer]) -> None:
435
+ """
436
+ Asynchronously write a list of lines to the spooled temporary file.
437
+
438
+ If the file has not yet been rolled over, the lines are written synchronously,
439
+ and a rollover is triggered if the size exceeds the maximum size.
440
+
441
+ :param lines: An iterable of lines to write.
442
+ :raises RuntimeError: If the underlying file is not initialized.
443
+
444
+ """
445
+ if not self._rolled:
446
+ await checkpoint_if_cancelled()
447
+ result = self._fp.writelines(lines)
448
+ await self._check()
449
+ return result
450
+
451
+ return await super().writelines(lines) # type: ignore[misc]
452
+
453
+
454
+ class TemporaryDirectory(Generic[AnyStr]):
455
+ """
456
+ An asynchronous temporary directory that is created and cleaned up automatically.
457
+
458
+ This class provides an asynchronous context manager for creating a temporary
459
+ directory. It wraps Python's standard :class:`~tempfile.TemporaryDirectory` to
460
+ perform directory creation and cleanup operations in a background thread.
461
+
462
+ :param suffix: Suffix to be added to the temporary directory name.
463
+ :param prefix: Prefix to be added to the temporary directory name.
464
+ :param dir: The parent directory where the temporary directory is created.
465
+ :param ignore_cleanup_errors: Whether to ignore errors during cleanup
466
+ (Python 3.10+).
467
+ :param delete: Whether to delete the directory upon closing (Python 3.12+).
468
+ """
469
+
470
+ def __init__(
471
+ self,
472
+ suffix: AnyStr | None = None,
473
+ prefix: AnyStr | None = None,
474
+ dir: AnyStr | None = None,
475
+ *,
476
+ ignore_cleanup_errors: bool = False,
477
+ delete: bool = True,
478
+ ) -> None:
479
+ self.suffix: AnyStr | None = suffix
480
+ self.prefix: AnyStr | None = prefix
481
+ self.dir: AnyStr | None = dir
482
+ self.ignore_cleanup_errors = ignore_cleanup_errors
483
+ self.delete = delete
484
+
485
+ self._tempdir: tempfile.TemporaryDirectory | None = None
486
+
487
+ async def __aenter__(self) -> str:
488
+ params: dict[str, Any] = {
489
+ "suffix": self.suffix,
490
+ "prefix": self.prefix,
491
+ "dir": self.dir,
492
+ }
493
+ if sys.version_info >= (3, 10):
494
+ params["ignore_cleanup_errors"] = self.ignore_cleanup_errors
495
+
496
+ if sys.version_info >= (3, 12):
497
+ params["delete"] = self.delete
498
+
499
+ self._tempdir = await to_thread.run_sync(
500
+ lambda: tempfile.TemporaryDirectory(**params)
501
+ )
502
+ return await to_thread.run_sync(self._tempdir.__enter__)
503
+
504
+ async def __aexit__(
505
+ self,
506
+ exc_type: type[BaseException] | None,
507
+ exc_value: BaseException | None,
508
+ traceback: TracebackType | None,
509
+ ) -> None:
510
+ if self._tempdir is not None:
511
+ await to_thread.run_sync(
512
+ self._tempdir.__exit__, exc_type, exc_value, traceback
513
+ )
514
+
515
+ async def cleanup(self) -> None:
516
+ if self._tempdir is not None:
517
+ await to_thread.run_sync(self._tempdir.cleanup)
518
+
519
+
520
+ @overload
521
+ async def mkstemp(
522
+ suffix: str | None = None,
523
+ prefix: str | None = None,
524
+ dir: str | None = None,
525
+ text: bool = False,
526
+ ) -> tuple[int, str]: ...
527
+
528
+
529
+ @overload
530
+ async def mkstemp(
531
+ suffix: bytes | None = None,
532
+ prefix: bytes | None = None,
533
+ dir: bytes | None = None,
534
+ text: bool = False,
535
+ ) -> tuple[int, bytes]: ...
536
+
537
+
538
+ async def mkstemp(
539
+ suffix: AnyStr | None = None,
540
+ prefix: AnyStr | None = None,
541
+ dir: AnyStr | None = None,
542
+ text: bool = False,
543
+ ) -> tuple[int, str | bytes]:
544
+ """
545
+ Asynchronously create a temporary file and return an OS-level handle and the file
546
+ name.
547
+
548
+ This function wraps `tempfile.mkstemp` and executes it in a background thread.
549
+
550
+ :param suffix: Suffix to be added to the file name.
551
+ :param prefix: Prefix to be added to the file name.
552
+ :param dir: Directory in which the temporary file is created.
553
+ :param text: Whether the file is opened in text mode.
554
+ :return: A tuple containing the file descriptor and the file name.
555
+
556
+ """
557
+ return await to_thread.run_sync(tempfile.mkstemp, suffix, prefix, dir, text)
558
+
559
+
560
+ @overload
561
+ async def mkdtemp(
562
+ suffix: str | None = None,
563
+ prefix: str | None = None,
564
+ dir: str | None = None,
565
+ ) -> str: ...
566
+
567
+
568
+ @overload
569
+ async def mkdtemp(
570
+ suffix: bytes | None = None,
571
+ prefix: bytes | None = None,
572
+ dir: bytes | None = None,
573
+ ) -> bytes: ...
574
+
575
+
576
+ async def mkdtemp(
577
+ suffix: AnyStr | None = None,
578
+ prefix: AnyStr | None = None,
579
+ dir: AnyStr | None = None,
580
+ ) -> str | bytes:
581
+ """
582
+ Asynchronously create a temporary directory and return its path.
583
+
584
+ This function wraps `tempfile.mkdtemp` and executes it in a background thread.
585
+
586
+ :param suffix: Suffix to be added to the directory name.
587
+ :param prefix: Prefix to be added to the directory name.
588
+ :param dir: Parent directory where the temporary directory is created.
589
+ :return: The path of the created temporary directory.
590
+
591
+ """
592
+ return await to_thread.run_sync(tempfile.mkdtemp, suffix, prefix, dir)
593
+
594
+
595
+ async def gettempdir() -> str:
596
+ """
597
+ Asynchronously return the name of the directory used for temporary files.
598
+
599
+ This function wraps `tempfile.gettempdir` and executes it in a background thread.
600
+
601
+ :return: The path of the temporary directory as a string.
602
+
603
+ """
604
+ return await to_thread.run_sync(tempfile.gettempdir)
605
+
606
+
607
+ async def gettempdirb() -> bytes:
608
+ """
609
+ Asynchronously return the name of the directory used for temporary files in bytes.
610
+
611
+ This function wraps `tempfile.gettempdirb` and executes it in a background thread.
612
+
613
+ :return: The path of the temporary directory as bytes.
614
+
615
+ """
616
+ return await to_thread.run_sync(tempfile.gettempdirb)
miniconda3/lib/python3.13/site-packages/anyio/_core/_testing.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Awaitable, Generator
4
+ from typing import Any, cast
5
+
6
+ from ._eventloop import get_async_backend
7
+
8
+
9
+ class TaskInfo:
10
+ """
11
+ Represents an asynchronous task.
12
+
13
+ :ivar int id: the unique identifier of the task
14
+ :ivar parent_id: the identifier of the parent task, if any
15
+ :vartype parent_id: Optional[int]
16
+ :ivar str name: the description of the task (if any)
17
+ :ivar ~collections.abc.Coroutine coro: the coroutine object of the task
18
+ """
19
+
20
+ __slots__ = "_name", "id", "parent_id", "name", "coro"
21
+
22
+ def __init__(
23
+ self,
24
+ id: int,
25
+ parent_id: int | None,
26
+ name: str | None,
27
+ coro: Generator[Any, Any, Any] | Awaitable[Any],
28
+ ):
29
+ func = get_current_task
30
+ self._name = f"{func.__module__}.{func.__qualname__}"
31
+ self.id: int = id
32
+ self.parent_id: int | None = parent_id
33
+ self.name: str | None = name
34
+ self.coro: Generator[Any, Any, Any] | Awaitable[Any] = coro
35
+
36
+ def __eq__(self, other: object) -> bool:
37
+ if isinstance(other, TaskInfo):
38
+ return self.id == other.id
39
+
40
+ return NotImplemented
41
+
42
+ def __hash__(self) -> int:
43
+ return hash(self.id)
44
+
45
+ def __repr__(self) -> str:
46
+ return f"{self.__class__.__name__}(id={self.id!r}, name={self.name!r})"
47
+
48
+ def has_pending_cancellation(self) -> bool:
49
+ """
50
+ Return ``True`` if the task has a cancellation pending, ``False`` otherwise.
51
+
52
+ """
53
+ return False
54
+
55
+
56
+ def get_current_task() -> TaskInfo:
57
+ """
58
+ Return the current task.
59
+
60
+ :return: a representation of the current task
61
+
62
+ """
63
+ return get_async_backend().get_current_task()
64
+
65
+
66
+ def get_running_tasks() -> list[TaskInfo]:
67
+ """
68
+ Return a list of running tasks in the current event loop.
69
+
70
+ :return: a list of task info objects
71
+
72
+ """
73
+ return cast("list[TaskInfo]", get_async_backend().get_running_tasks())
74
+
75
+
76
+ async def wait_all_tasks_blocked() -> None:
77
+ """Wait until all other tasks are waiting for something."""
78
+ await get_async_backend().wait_all_tasks_blocked()
miniconda3/lib/python3.13/site-packages/anyio/_core/_typedattr.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Callable, Mapping
4
+ from typing import Any, TypeVar, final, overload
5
+
6
+ from ._exceptions import TypedAttributeLookupError
7
+
8
+ T_Attr = TypeVar("T_Attr")
9
+ T_Default = TypeVar("T_Default")
10
+ undefined = object()
11
+
12
+
13
+ def typed_attribute() -> Any:
14
+ """Return a unique object, used to mark typed attributes."""
15
+ return object()
16
+
17
+
18
+ class TypedAttributeSet:
19
+ """
20
+ Superclass for typed attribute collections.
21
+
22
+ Checks that every public attribute of every subclass has a type annotation.
23
+ """
24
+
25
+ def __init_subclass__(cls) -> None:
26
+ annotations: dict[str, Any] = getattr(cls, "__annotations__", {})
27
+ for attrname in dir(cls):
28
+ if not attrname.startswith("_") and attrname not in annotations:
29
+ raise TypeError(
30
+ f"Attribute {attrname!r} is missing its type annotation"
31
+ )
32
+
33
+ super().__init_subclass__()
34
+
35
+
36
+ class TypedAttributeProvider:
37
+ """Base class for classes that wish to provide typed extra attributes."""
38
+
39
+ @property
40
+ def extra_attributes(self) -> Mapping[T_Attr, Callable[[], T_Attr]]:
41
+ """
42
+ A mapping of the extra attributes to callables that return the corresponding
43
+ values.
44
+
45
+ If the provider wraps another provider, the attributes from that wrapper should
46
+ also be included in the returned mapping (but the wrapper may override the
47
+ callables from the wrapped instance).
48
+
49
+ """
50
+ return {}
51
+
52
+ @overload
53
+ def extra(self, attribute: T_Attr) -> T_Attr: ...
54
+
55
+ @overload
56
+ def extra(self, attribute: T_Attr, default: T_Default) -> T_Attr | T_Default: ...
57
+
58
+ @final
59
+ def extra(self, attribute: Any, default: object = undefined) -> object:
60
+ """
61
+ extra(attribute, default=undefined)
62
+
63
+ Return the value of the given typed extra attribute.
64
+
65
+ :param attribute: the attribute (member of a :class:`~TypedAttributeSet`) to
66
+ look for
67
+ :param default: the value that should be returned if no value is found for the
68
+ attribute
69
+ :raises ~anyio.TypedAttributeLookupError: if the search failed and no default
70
+ value was given
71
+
72
+ """
73
+ try:
74
+ getter = self.extra_attributes[attribute]
75
+ except KeyError:
76
+ if default is undefined:
77
+ raise TypedAttributeLookupError("Attribute not found") from None
78
+ else:
79
+ return default
80
+
81
+ return getter()
miniconda3/lib/python3.13/site-packages/anyio/abc/__init__.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ._eventloop import AsyncBackend as AsyncBackend
4
+ from ._resources import AsyncResource as AsyncResource
5
+ from ._sockets import ConnectedUDPSocket as ConnectedUDPSocket
6
+ from ._sockets import ConnectedUNIXDatagramSocket as ConnectedUNIXDatagramSocket
7
+ from ._sockets import IPAddressType as IPAddressType
8
+ from ._sockets import IPSockAddrType as IPSockAddrType
9
+ from ._sockets import SocketAttribute as SocketAttribute
10
+ from ._sockets import SocketListener as SocketListener
11
+ from ._sockets import SocketStream as SocketStream
12
+ from ._sockets import UDPPacketType as UDPPacketType
13
+ from ._sockets import UDPSocket as UDPSocket
14
+ from ._sockets import UNIXDatagramPacketType as UNIXDatagramPacketType
15
+ from ._sockets import UNIXDatagramSocket as UNIXDatagramSocket
16
+ from ._sockets import UNIXSocketStream as UNIXSocketStream
17
+ from ._streams import AnyByteReceiveStream as AnyByteReceiveStream
18
+ from ._streams import AnyByteSendStream as AnyByteSendStream
19
+ from ._streams import AnyByteStream as AnyByteStream
20
+ from ._streams import AnyByteStreamConnectable as AnyByteStreamConnectable
21
+ from ._streams import AnyUnreliableByteReceiveStream as AnyUnreliableByteReceiveStream
22
+ from ._streams import AnyUnreliableByteSendStream as AnyUnreliableByteSendStream
23
+ from ._streams import AnyUnreliableByteStream as AnyUnreliableByteStream
24
+ from ._streams import ByteReceiveStream as ByteReceiveStream
25
+ from ._streams import ByteSendStream as ByteSendStream
26
+ from ._streams import ByteStream as ByteStream
27
+ from ._streams import ByteStreamConnectable as ByteStreamConnectable
28
+ from ._streams import Listener as Listener
29
+ from ._streams import ObjectReceiveStream as ObjectReceiveStream
30
+ from ._streams import ObjectSendStream as ObjectSendStream
31
+ from ._streams import ObjectStream as ObjectStream
32
+ from ._streams import ObjectStreamConnectable as ObjectStreamConnectable
33
+ from ._streams import UnreliableObjectReceiveStream as UnreliableObjectReceiveStream
34
+ from ._streams import UnreliableObjectSendStream as UnreliableObjectSendStream
35
+ from ._streams import UnreliableObjectStream as UnreliableObjectStream
36
+ from ._subprocesses import Process as Process
37
+ from ._tasks import TaskGroup as TaskGroup
38
+ from ._tasks import TaskStatus as TaskStatus
39
+ from ._testing import TestRunner as TestRunner
40
+
41
+ # Re-exported here, for backwards compatibility
42
+ # isort: off
43
+ from .._core._synchronization import (
44
+ CapacityLimiter as CapacityLimiter,
45
+ Condition as Condition,
46
+ Event as Event,
47
+ Lock as Lock,
48
+ Semaphore as Semaphore,
49
+ )
50
+ from .._core._tasks import CancelScope as CancelScope
51
+ from ..from_thread import BlockingPortal as BlockingPortal
52
+
53
+ # Re-export imports so they look like they live directly in this package
54
+ for __value in list(locals().values()):
55
+ if getattr(__value, "__module__", "").startswith("anyio.abc."):
56
+ __value.__module__ = __name__
57
+
58
+ del __value
miniconda3/lib/python3.13/site-packages/anyio/abc/_eventloop.py ADDED
@@ -0,0 +1,418 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import math
4
+ import sys
5
+ from abc import ABCMeta, abstractmethod
6
+ from collections.abc import AsyncIterator, Awaitable, Callable, Sequence
7
+ from contextlib import AbstractContextManager
8
+ from os import PathLike
9
+ from signal import Signals
10
+ from socket import AddressFamily, SocketKind, socket
11
+ from typing import (
12
+ IO,
13
+ TYPE_CHECKING,
14
+ Any,
15
+ TypeVar,
16
+ Union,
17
+ overload,
18
+ )
19
+
20
+ if sys.version_info >= (3, 11):
21
+ from typing import TypeVarTuple, Unpack
22
+ else:
23
+ from typing_extensions import TypeVarTuple, Unpack
24
+
25
+ if sys.version_info >= (3, 10):
26
+ from typing import TypeAlias
27
+ else:
28
+ from typing_extensions import TypeAlias
29
+
30
+ if TYPE_CHECKING:
31
+ from _typeshed import FileDescriptorLike
32
+
33
+ from .._core._synchronization import CapacityLimiter, Event, Lock, Semaphore
34
+ from .._core._tasks import CancelScope
35
+ from .._core._testing import TaskInfo
36
+ from ..from_thread import BlockingPortal
37
+ from ._sockets import (
38
+ ConnectedUDPSocket,
39
+ ConnectedUNIXDatagramSocket,
40
+ IPSockAddrType,
41
+ SocketListener,
42
+ SocketStream,
43
+ UDPSocket,
44
+ UNIXDatagramSocket,
45
+ UNIXSocketStream,
46
+ )
47
+ from ._subprocesses import Process
48
+ from ._tasks import TaskGroup
49
+ from ._testing import TestRunner
50
+
51
+ T_Retval = TypeVar("T_Retval")
52
+ PosArgsT = TypeVarTuple("PosArgsT")
53
+ StrOrBytesPath: TypeAlias = Union[str, bytes, "PathLike[str]", "PathLike[bytes]"]
54
+
55
+
56
+ class AsyncBackend(metaclass=ABCMeta):
57
+ @classmethod
58
+ @abstractmethod
59
+ def run(
60
+ cls,
61
+ func: Callable[[Unpack[PosArgsT]], Awaitable[T_Retval]],
62
+ args: tuple[Unpack[PosArgsT]],
63
+ kwargs: dict[str, Any],
64
+ options: dict[str, Any],
65
+ ) -> T_Retval:
66
+ """
67
+ Run the given coroutine function in an asynchronous event loop.
68
+
69
+ The current thread must not be already running an event loop.
70
+
71
+ :param func: a coroutine function
72
+ :param args: positional arguments to ``func``
73
+ :param kwargs: positional arguments to ``func``
74
+ :param options: keyword arguments to call the backend ``run()`` implementation
75
+ with
76
+ :return: the return value of the coroutine function
77
+ """
78
+
79
+ @classmethod
80
+ @abstractmethod
81
+ def current_token(cls) -> object:
82
+ """
83
+
84
+ :return:
85
+ """
86
+
87
+ @classmethod
88
+ @abstractmethod
89
+ def current_time(cls) -> float:
90
+ """
91
+ Return the current value of the event loop's internal clock.
92
+
93
+ :return: the clock value (seconds)
94
+ """
95
+
96
+ @classmethod
97
+ @abstractmethod
98
+ def cancelled_exception_class(cls) -> type[BaseException]:
99
+ """Return the exception class that is raised in a task if it's cancelled."""
100
+
101
+ @classmethod
102
+ @abstractmethod
103
+ async def checkpoint(cls) -> None:
104
+ """
105
+ Check if the task has been cancelled, and allow rescheduling of other tasks.
106
+
107
+ This is effectively the same as running :meth:`checkpoint_if_cancelled` and then
108
+ :meth:`cancel_shielded_checkpoint`.
109
+ """
110
+
111
+ @classmethod
112
+ async def checkpoint_if_cancelled(cls) -> None:
113
+ """
114
+ Check if the current task group has been cancelled.
115
+
116
+ This will check if the task has been cancelled, but will not allow other tasks
117
+ to be scheduled if not.
118
+
119
+ """
120
+ if cls.current_effective_deadline() == -math.inf:
121
+ await cls.checkpoint()
122
+
123
+ @classmethod
124
+ async def cancel_shielded_checkpoint(cls) -> None:
125
+ """
126
+ Allow the rescheduling of other tasks.
127
+
128
+ This will give other tasks the opportunity to run, but without checking if the
129
+ current task group has been cancelled, unlike with :meth:`checkpoint`.
130
+
131
+ """
132
+ with cls.create_cancel_scope(shield=True):
133
+ await cls.sleep(0)
134
+
135
+ @classmethod
136
+ @abstractmethod
137
+ async def sleep(cls, delay: float) -> None:
138
+ """
139
+ Pause the current task for the specified duration.
140
+
141
+ :param delay: the duration, in seconds
142
+ """
143
+
144
+ @classmethod
145
+ @abstractmethod
146
+ def create_cancel_scope(
147
+ cls, *, deadline: float = math.inf, shield: bool = False
148
+ ) -> CancelScope:
149
+ pass
150
+
151
+ @classmethod
152
+ @abstractmethod
153
+ def current_effective_deadline(cls) -> float:
154
+ """
155
+ Return the nearest deadline among all the cancel scopes effective for the
156
+ current task.
157
+
158
+ :return:
159
+ - a clock value from the event loop's internal clock
160
+ - ``inf`` if there is no deadline in effect
161
+ - ``-inf`` if the current scope has been cancelled
162
+ :rtype: float
163
+ """
164
+
165
+ @classmethod
166
+ @abstractmethod
167
+ def create_task_group(cls) -> TaskGroup:
168
+ pass
169
+
170
+ @classmethod
171
+ @abstractmethod
172
+ def create_event(cls) -> Event:
173
+ pass
174
+
175
+ @classmethod
176
+ @abstractmethod
177
+ def create_lock(cls, *, fast_acquire: bool) -> Lock:
178
+ pass
179
+
180
+ @classmethod
181
+ @abstractmethod
182
+ def create_semaphore(
183
+ cls,
184
+ initial_value: int,
185
+ *,
186
+ max_value: int | None = None,
187
+ fast_acquire: bool = False,
188
+ ) -> Semaphore:
189
+ pass
190
+
191
+ @classmethod
192
+ @abstractmethod
193
+ def create_capacity_limiter(cls, total_tokens: float) -> CapacityLimiter:
194
+ pass
195
+
196
+ @classmethod
197
+ @abstractmethod
198
+ async def run_sync_in_worker_thread(
199
+ cls,
200
+ func: Callable[[Unpack[PosArgsT]], T_Retval],
201
+ args: tuple[Unpack[PosArgsT]],
202
+ abandon_on_cancel: bool = False,
203
+ limiter: CapacityLimiter | None = None,
204
+ ) -> T_Retval:
205
+ pass
206
+
207
+ @classmethod
208
+ @abstractmethod
209
+ def check_cancelled(cls) -> None:
210
+ pass
211
+
212
+ @classmethod
213
+ @abstractmethod
214
+ def run_async_from_thread(
215
+ cls,
216
+ func: Callable[[Unpack[PosArgsT]], Awaitable[T_Retval]],
217
+ args: tuple[Unpack[PosArgsT]],
218
+ token: object,
219
+ ) -> T_Retval:
220
+ pass
221
+
222
+ @classmethod
223
+ @abstractmethod
224
+ def run_sync_from_thread(
225
+ cls,
226
+ func: Callable[[Unpack[PosArgsT]], T_Retval],
227
+ args: tuple[Unpack[PosArgsT]],
228
+ token: object,
229
+ ) -> T_Retval:
230
+ pass
231
+
232
+ @classmethod
233
+ @abstractmethod
234
+ def create_blocking_portal(cls) -> BlockingPortal:
235
+ pass
236
+
237
+ @classmethod
238
+ @abstractmethod
239
+ async def open_process(
240
+ cls,
241
+ command: StrOrBytesPath | Sequence[StrOrBytesPath],
242
+ *,
243
+ stdin: int | IO[Any] | None,
244
+ stdout: int | IO[Any] | None,
245
+ stderr: int | IO[Any] | None,
246
+ **kwargs: Any,
247
+ ) -> Process:
248
+ pass
249
+
250
+ @classmethod
251
+ @abstractmethod
252
+ def setup_process_pool_exit_at_shutdown(cls, workers: set[Process]) -> None:
253
+ pass
254
+
255
+ @classmethod
256
+ @abstractmethod
257
+ async def connect_tcp(
258
+ cls, host: str, port: int, local_address: IPSockAddrType | None = None
259
+ ) -> SocketStream:
260
+ pass
261
+
262
+ @classmethod
263
+ @abstractmethod
264
+ async def connect_unix(cls, path: str | bytes) -> UNIXSocketStream:
265
+ pass
266
+
267
+ @classmethod
268
+ @abstractmethod
269
+ def create_tcp_listener(cls, sock: socket) -> SocketListener:
270
+ pass
271
+
272
+ @classmethod
273
+ @abstractmethod
274
+ def create_unix_listener(cls, sock: socket) -> SocketListener:
275
+ pass
276
+
277
+ @classmethod
278
+ @abstractmethod
279
+ async def create_udp_socket(
280
+ cls,
281
+ family: AddressFamily,
282
+ local_address: IPSockAddrType | None,
283
+ remote_address: IPSockAddrType | None,
284
+ reuse_port: bool,
285
+ ) -> UDPSocket | ConnectedUDPSocket:
286
+ pass
287
+
288
+ @classmethod
289
+ @overload
290
+ async def create_unix_datagram_socket(
291
+ cls, raw_socket: socket, remote_path: None
292
+ ) -> UNIXDatagramSocket: ...
293
+
294
+ @classmethod
295
+ @overload
296
+ async def create_unix_datagram_socket(
297
+ cls, raw_socket: socket, remote_path: str | bytes
298
+ ) -> ConnectedUNIXDatagramSocket: ...
299
+
300
+ @classmethod
301
+ @abstractmethod
302
+ async def create_unix_datagram_socket(
303
+ cls, raw_socket: socket, remote_path: str | bytes | None
304
+ ) -> UNIXDatagramSocket | ConnectedUNIXDatagramSocket:
305
+ pass
306
+
307
+ @classmethod
308
+ @abstractmethod
309
+ async def getaddrinfo(
310
+ cls,
311
+ host: bytes | str | None,
312
+ port: str | int | None,
313
+ *,
314
+ family: int | AddressFamily = 0,
315
+ type: int | SocketKind = 0,
316
+ proto: int = 0,
317
+ flags: int = 0,
318
+ ) -> Sequence[
319
+ tuple[
320
+ AddressFamily,
321
+ SocketKind,
322
+ int,
323
+ str,
324
+ tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes],
325
+ ]
326
+ ]:
327
+ pass
328
+
329
+ @classmethod
330
+ @abstractmethod
331
+ async def getnameinfo(
332
+ cls, sockaddr: IPSockAddrType, flags: int = 0
333
+ ) -> tuple[str, str]:
334
+ pass
335
+
336
+ @classmethod
337
+ @abstractmethod
338
+ async def wait_readable(cls, obj: FileDescriptorLike) -> None:
339
+ pass
340
+
341
+ @classmethod
342
+ @abstractmethod
343
+ async def wait_writable(cls, obj: FileDescriptorLike) -> None:
344
+ pass
345
+
346
+ @classmethod
347
+ @abstractmethod
348
+ def notify_closing(cls, obj: FileDescriptorLike) -> None:
349
+ pass
350
+
351
+ @classmethod
352
+ @abstractmethod
353
+ async def wrap_listener_socket(cls, sock: socket) -> SocketListener:
354
+ pass
355
+
356
+ @classmethod
357
+ @abstractmethod
358
+ async def wrap_stream_socket(cls, sock: socket) -> SocketStream:
359
+ pass
360
+
361
+ @classmethod
362
+ @abstractmethod
363
+ async def wrap_unix_stream_socket(cls, sock: socket) -> UNIXSocketStream:
364
+ pass
365
+
366
+ @classmethod
367
+ @abstractmethod
368
+ async def wrap_udp_socket(cls, sock: socket) -> UDPSocket:
369
+ pass
370
+
371
+ @classmethod
372
+ @abstractmethod
373
+ async def wrap_connected_udp_socket(cls, sock: socket) -> ConnectedUDPSocket:
374
+ pass
375
+
376
+ @classmethod
377
+ @abstractmethod
378
+ async def wrap_unix_datagram_socket(cls, sock: socket) -> UNIXDatagramSocket:
379
+ pass
380
+
381
+ @classmethod
382
+ @abstractmethod
383
+ async def wrap_connected_unix_datagram_socket(
384
+ cls, sock: socket
385
+ ) -> ConnectedUNIXDatagramSocket:
386
+ pass
387
+
388
+ @classmethod
389
+ @abstractmethod
390
+ def current_default_thread_limiter(cls) -> CapacityLimiter:
391
+ pass
392
+
393
+ @classmethod
394
+ @abstractmethod
395
+ def open_signal_receiver(
396
+ cls, *signals: Signals
397
+ ) -> AbstractContextManager[AsyncIterator[Signals]]:
398
+ pass
399
+
400
+ @classmethod
401
+ @abstractmethod
402
+ def get_current_task(cls) -> TaskInfo:
403
+ pass
404
+
405
+ @classmethod
406
+ @abstractmethod
407
+ def get_running_tasks(cls) -> Sequence[TaskInfo]:
408
+ pass
409
+
410
+ @classmethod
411
+ @abstractmethod
412
+ async def wait_all_tasks_blocked(cls) -> None:
413
+ pass
414
+
415
+ @classmethod
416
+ @abstractmethod
417
+ def create_test_runner(cls, options: dict[str, Any]) -> TestRunner:
418
+ pass
miniconda3/lib/python3.13/site-packages/anyio/abc/_resources.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from abc import ABCMeta, abstractmethod
4
+ from types import TracebackType
5
+ from typing import TypeVar
6
+
7
+ T = TypeVar("T")
8
+
9
+
10
+ class AsyncResource(metaclass=ABCMeta):
11
+ """
12
+ Abstract base class for all closeable asynchronous resources.
13
+
14
+ Works as an asynchronous context manager which returns the instance itself on enter,
15
+ and calls :meth:`aclose` on exit.
16
+ """
17
+
18
+ __slots__ = ()
19
+
20
+ async def __aenter__(self: T) -> T:
21
+ return self
22
+
23
+ async def __aexit__(
24
+ self,
25
+ exc_type: type[BaseException] | None,
26
+ exc_val: BaseException | None,
27
+ exc_tb: TracebackType | None,
28
+ ) -> None:
29
+ await self.aclose()
30
+
31
+ @abstractmethod
32
+ async def aclose(self) -> None:
33
+ """Close the resource."""
miniconda3/lib/python3.13/site-packages/anyio/abc/_sockets.py ADDED
@@ -0,0 +1,405 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import errno
4
+ import socket
5
+ import sys
6
+ from abc import abstractmethod
7
+ from collections.abc import Callable, Collection, Mapping
8
+ from contextlib import AsyncExitStack
9
+ from io import IOBase
10
+ from ipaddress import IPv4Address, IPv6Address
11
+ from socket import AddressFamily
12
+ from typing import Any, TypeVar, Union
13
+
14
+ from .._core._eventloop import get_async_backend
15
+ from .._core._typedattr import (
16
+ TypedAttributeProvider,
17
+ TypedAttributeSet,
18
+ typed_attribute,
19
+ )
20
+ from ._streams import ByteStream, Listener, UnreliableObjectStream
21
+ from ._tasks import TaskGroup
22
+
23
+ if sys.version_info >= (3, 10):
24
+ from typing import TypeAlias
25
+ else:
26
+ from typing_extensions import TypeAlias
27
+
28
+ IPAddressType: TypeAlias = Union[str, IPv4Address, IPv6Address]
29
+ IPSockAddrType: TypeAlias = tuple[str, int]
30
+ SockAddrType: TypeAlias = Union[IPSockAddrType, str]
31
+ UDPPacketType: TypeAlias = tuple[bytes, IPSockAddrType]
32
+ UNIXDatagramPacketType: TypeAlias = tuple[bytes, str]
33
+ T_Retval = TypeVar("T_Retval")
34
+
35
+
36
+ def _validate_socket(
37
+ sock_or_fd: socket.socket | int,
38
+ sock_type: socket.SocketKind,
39
+ addr_family: socket.AddressFamily = socket.AF_UNSPEC,
40
+ *,
41
+ require_connected: bool = False,
42
+ require_bound: bool = False,
43
+ ) -> socket.socket:
44
+ if isinstance(sock_or_fd, int):
45
+ try:
46
+ sock = socket.socket(fileno=sock_or_fd)
47
+ except OSError as exc:
48
+ if exc.errno == errno.ENOTSOCK:
49
+ raise ValueError(
50
+ "the file descriptor does not refer to a socket"
51
+ ) from exc
52
+ elif require_connected:
53
+ raise ValueError("the socket must be connected") from exc
54
+ elif require_bound:
55
+ raise ValueError("the socket must be bound to a local address") from exc
56
+ else:
57
+ raise
58
+ elif isinstance(sock_or_fd, socket.socket):
59
+ sock = sock_or_fd
60
+ else:
61
+ raise TypeError(
62
+ f"expected an int or socket, got {type(sock_or_fd).__qualname__} instead"
63
+ )
64
+
65
+ try:
66
+ if require_connected:
67
+ try:
68
+ sock.getpeername()
69
+ except OSError as exc:
70
+ raise ValueError("the socket must be connected") from exc
71
+
72
+ if require_bound:
73
+ try:
74
+ if sock.family in (socket.AF_INET, socket.AF_INET6):
75
+ bound_addr = sock.getsockname()[1]
76
+ else:
77
+ bound_addr = sock.getsockname()
78
+ except OSError:
79
+ bound_addr = None
80
+
81
+ if not bound_addr:
82
+ raise ValueError("the socket must be bound to a local address")
83
+
84
+ if addr_family != socket.AF_UNSPEC and sock.family != addr_family:
85
+ raise ValueError(
86
+ f"address family mismatch: expected {addr_family.name}, got "
87
+ f"{sock.family.name}"
88
+ )
89
+
90
+ if sock.type != sock_type:
91
+ raise ValueError(
92
+ f"socket type mismatch: expected {sock_type.name}, got {sock.type.name}"
93
+ )
94
+ except BaseException:
95
+ # Avoid ResourceWarning from the locally constructed socket object
96
+ if isinstance(sock_or_fd, int):
97
+ sock.detach()
98
+
99
+ raise
100
+
101
+ sock.setblocking(False)
102
+ return sock
103
+
104
+
105
+ class SocketAttribute(TypedAttributeSet):
106
+ """
107
+ .. attribute:: family
108
+ :type: socket.AddressFamily
109
+
110
+ the address family of the underlying socket
111
+
112
+ .. attribute:: local_address
113
+ :type: tuple[str, int] | str
114
+
115
+ the local address the underlying socket is connected to
116
+
117
+ .. attribute:: local_port
118
+ :type: int
119
+
120
+ for IP based sockets, the local port the underlying socket is bound to
121
+
122
+ .. attribute:: raw_socket
123
+ :type: socket.socket
124
+
125
+ the underlying stdlib socket object
126
+
127
+ .. attribute:: remote_address
128
+ :type: tuple[str, int] | str
129
+
130
+ the remote address the underlying socket is connected to
131
+
132
+ .. attribute:: remote_port
133
+ :type: int
134
+
135
+ for IP based sockets, the remote port the underlying socket is connected to
136
+ """
137
+
138
+ family: AddressFamily = typed_attribute()
139
+ local_address: SockAddrType = typed_attribute()
140
+ local_port: int = typed_attribute()
141
+ raw_socket: socket.socket = typed_attribute()
142
+ remote_address: SockAddrType = typed_attribute()
143
+ remote_port: int = typed_attribute()
144
+
145
+
146
+ class _SocketProvider(TypedAttributeProvider):
147
+ @property
148
+ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
149
+ from .._core._sockets import convert_ipv6_sockaddr as convert
150
+
151
+ attributes: dict[Any, Callable[[], Any]] = {
152
+ SocketAttribute.family: lambda: self._raw_socket.family,
153
+ SocketAttribute.local_address: lambda: convert(
154
+ self._raw_socket.getsockname()
155
+ ),
156
+ SocketAttribute.raw_socket: lambda: self._raw_socket,
157
+ }
158
+ try:
159
+ peername: tuple[str, int] | None = convert(self._raw_socket.getpeername())
160
+ except OSError:
161
+ peername = None
162
+
163
+ # Provide the remote address for connected sockets
164
+ if peername is not None:
165
+ attributes[SocketAttribute.remote_address] = lambda: peername
166
+
167
+ # Provide local and remote ports for IP based sockets
168
+ if self._raw_socket.family in (AddressFamily.AF_INET, AddressFamily.AF_INET6):
169
+ attributes[SocketAttribute.local_port] = (
170
+ lambda: self._raw_socket.getsockname()[1]
171
+ )
172
+ if peername is not None:
173
+ remote_port = peername[1]
174
+ attributes[SocketAttribute.remote_port] = lambda: remote_port
175
+
176
+ return attributes
177
+
178
+ @property
179
+ @abstractmethod
180
+ def _raw_socket(self) -> socket.socket:
181
+ pass
182
+
183
+
184
+ class SocketStream(ByteStream, _SocketProvider):
185
+ """
186
+ Transports bytes over a socket.
187
+
188
+ Supports all relevant extra attributes from :class:`~SocketAttribute`.
189
+ """
190
+
191
+ @classmethod
192
+ async def from_socket(cls, sock_or_fd: socket.socket | int) -> SocketStream:
193
+ """
194
+ Wrap an existing socket object or file descriptor as a socket stream.
195
+
196
+ The newly created socket wrapper takes ownership of the socket being passed in.
197
+ The existing socket must already be connected.
198
+
199
+ :param sock_or_fd: a socket object or file descriptor
200
+ :return: a socket stream
201
+
202
+ """
203
+ sock = _validate_socket(sock_or_fd, socket.SOCK_STREAM, require_connected=True)
204
+ return await get_async_backend().wrap_stream_socket(sock)
205
+
206
+
207
+ class UNIXSocketStream(SocketStream):
208
+ @classmethod
209
+ async def from_socket(cls, sock_or_fd: socket.socket | int) -> UNIXSocketStream:
210
+ """
211
+ Wrap an existing socket object or file descriptor as a UNIX socket stream.
212
+
213
+ The newly created socket wrapper takes ownership of the socket being passed in.
214
+ The existing socket must already be connected.
215
+
216
+ :param sock_or_fd: a socket object or file descriptor
217
+ :return: a UNIX socket stream
218
+
219
+ """
220
+ sock = _validate_socket(
221
+ sock_or_fd, socket.SOCK_STREAM, socket.AF_UNIX, require_connected=True
222
+ )
223
+ return await get_async_backend().wrap_unix_stream_socket(sock)
224
+
225
+ @abstractmethod
226
+ async def send_fds(self, message: bytes, fds: Collection[int | IOBase]) -> None:
227
+ """
228
+ Send file descriptors along with a message to the peer.
229
+
230
+ :param message: a non-empty bytestring
231
+ :param fds: a collection of files (either numeric file descriptors or open file
232
+ or socket objects)
233
+ """
234
+
235
+ @abstractmethod
236
+ async def receive_fds(self, msglen: int, maxfds: int) -> tuple[bytes, list[int]]:
237
+ """
238
+ Receive file descriptors along with a message from the peer.
239
+
240
+ :param msglen: length of the message to expect from the peer
241
+ :param maxfds: maximum number of file descriptors to expect from the peer
242
+ :return: a tuple of (message, file descriptors)
243
+ """
244
+
245
+
246
+ class SocketListener(Listener[SocketStream], _SocketProvider):
247
+ """
248
+ Listens to incoming socket connections.
249
+
250
+ Supports all relevant extra attributes from :class:`~SocketAttribute`.
251
+ """
252
+
253
+ @classmethod
254
+ async def from_socket(
255
+ cls,
256
+ sock_or_fd: socket.socket | int,
257
+ ) -> SocketListener:
258
+ """
259
+ Wrap an existing socket object or file descriptor as a socket listener.
260
+
261
+ The newly created listener takes ownership of the socket being passed in.
262
+
263
+ :param sock_or_fd: a socket object or file descriptor
264
+ :return: a socket listener
265
+
266
+ """
267
+ sock = _validate_socket(sock_or_fd, socket.SOCK_STREAM, require_bound=True)
268
+ return await get_async_backend().wrap_listener_socket(sock)
269
+
270
+ @abstractmethod
271
+ async def accept(self) -> SocketStream:
272
+ """Accept an incoming connection."""
273
+
274
+ async def serve(
275
+ self,
276
+ handler: Callable[[SocketStream], Any],
277
+ task_group: TaskGroup | None = None,
278
+ ) -> None:
279
+ from .. import create_task_group
280
+
281
+ async with AsyncExitStack() as stack:
282
+ if task_group is None:
283
+ task_group = await stack.enter_async_context(create_task_group())
284
+
285
+ while True:
286
+ stream = await self.accept()
287
+ task_group.start_soon(handler, stream)
288
+
289
+
290
+ class UDPSocket(UnreliableObjectStream[UDPPacketType], _SocketProvider):
291
+ """
292
+ Represents an unconnected UDP socket.
293
+
294
+ Supports all relevant extra attributes from :class:`~SocketAttribute`.
295
+ """
296
+
297
+ @classmethod
298
+ async def from_socket(cls, sock_or_fd: socket.socket | int) -> UDPSocket:
299
+ """
300
+ Wrap an existing socket object or file descriptor as a UDP socket.
301
+
302
+ The newly created socket wrapper takes ownership of the socket being passed in.
303
+ The existing socket must be bound to a local address.
304
+
305
+ :param sock_or_fd: a socket object or file descriptor
306
+ :return: a UDP socket
307
+
308
+ """
309
+ sock = _validate_socket(sock_or_fd, socket.SOCK_DGRAM, require_bound=True)
310
+ return await get_async_backend().wrap_udp_socket(sock)
311
+
312
+ async def sendto(self, data: bytes, host: str, port: int) -> None:
313
+ """
314
+ Alias for :meth:`~.UnreliableObjectSendStream.send` ((data, (host, port))).
315
+
316
+ """
317
+ return await self.send((data, (host, port)))
318
+
319
+
320
+ class ConnectedUDPSocket(UnreliableObjectStream[bytes], _SocketProvider):
321
+ """
322
+ Represents an connected UDP socket.
323
+
324
+ Supports all relevant extra attributes from :class:`~SocketAttribute`.
325
+ """
326
+
327
+ @classmethod
328
+ async def from_socket(cls, sock_or_fd: socket.socket | int) -> ConnectedUDPSocket:
329
+ """
330
+ Wrap an existing socket object or file descriptor as a connected UDP socket.
331
+
332
+ The newly created socket wrapper takes ownership of the socket being passed in.
333
+ The existing socket must already be connected.
334
+
335
+ :param sock_or_fd: a socket object or file descriptor
336
+ :return: a connected UDP socket
337
+
338
+ """
339
+ sock = _validate_socket(
340
+ sock_or_fd,
341
+ socket.SOCK_DGRAM,
342
+ require_connected=True,
343
+ )
344
+ return await get_async_backend().wrap_connected_udp_socket(sock)
345
+
346
+
347
+ class UNIXDatagramSocket(
348
+ UnreliableObjectStream[UNIXDatagramPacketType], _SocketProvider
349
+ ):
350
+ """
351
+ Represents an unconnected Unix datagram socket.
352
+
353
+ Supports all relevant extra attributes from :class:`~SocketAttribute`.
354
+ """
355
+
356
+ @classmethod
357
+ async def from_socket(
358
+ cls,
359
+ sock_or_fd: socket.socket | int,
360
+ ) -> UNIXDatagramSocket:
361
+ """
362
+ Wrap an existing socket object or file descriptor as a UNIX datagram
363
+ socket.
364
+
365
+ The newly created socket wrapper takes ownership of the socket being passed in.
366
+
367
+ :param sock_or_fd: a socket object or file descriptor
368
+ :return: a UNIX datagram socket
369
+
370
+ """
371
+ sock = _validate_socket(sock_or_fd, socket.SOCK_DGRAM, socket.AF_UNIX)
372
+ return await get_async_backend().wrap_unix_datagram_socket(sock)
373
+
374
+ async def sendto(self, data: bytes, path: str) -> None:
375
+ """Alias for :meth:`~.UnreliableObjectSendStream.send` ((data, path))."""
376
+ return await self.send((data, path))
377
+
378
+
379
+ class ConnectedUNIXDatagramSocket(UnreliableObjectStream[bytes], _SocketProvider):
380
+ """
381
+ Represents a connected Unix datagram socket.
382
+
383
+ Supports all relevant extra attributes from :class:`~SocketAttribute`.
384
+ """
385
+
386
+ @classmethod
387
+ async def from_socket(
388
+ cls,
389
+ sock_or_fd: socket.socket | int,
390
+ ) -> ConnectedUNIXDatagramSocket:
391
+ """
392
+ Wrap an existing socket object or file descriptor as a connected UNIX datagram
393
+ socket.
394
+
395
+ The newly created socket wrapper takes ownership of the socket being passed in.
396
+ The existing socket must already be connected.
397
+
398
+ :param sock_or_fd: a socket object or file descriptor
399
+ :return: a connected UNIX datagram socket
400
+
401
+ """
402
+ sock = _validate_socket(
403
+ sock_or_fd, socket.SOCK_DGRAM, socket.AF_UNIX, require_connected=True
404
+ )
405
+ return await get_async_backend().wrap_connected_unix_datagram_socket(sock)
miniconda3/lib/python3.13/site-packages/anyio/abc/_streams.py ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ from abc import ABCMeta, abstractmethod
5
+ from collections.abc import Callable
6
+ from typing import Any, Generic, TypeVar, Union
7
+
8
+ from .._core._exceptions import EndOfStream
9
+ from .._core._typedattr import TypedAttributeProvider
10
+ from ._resources import AsyncResource
11
+ from ._tasks import TaskGroup
12
+
13
+ if sys.version_info >= (3, 10):
14
+ from typing import TypeAlias
15
+ else:
16
+ from typing_extensions import TypeAlias
17
+
18
+ T_Item = TypeVar("T_Item")
19
+ T_co = TypeVar("T_co", covariant=True)
20
+ T_contra = TypeVar("T_contra", contravariant=True)
21
+
22
+
23
+ class UnreliableObjectReceiveStream(
24
+ Generic[T_co], AsyncResource, TypedAttributeProvider
25
+ ):
26
+ """
27
+ An interface for receiving objects.
28
+
29
+ This interface makes no guarantees that the received messages arrive in the order in
30
+ which they were sent, or that no messages are missed.
31
+
32
+ Asynchronously iterating over objects of this type will yield objects matching the
33
+ given type parameter.
34
+ """
35
+
36
+ def __aiter__(self) -> UnreliableObjectReceiveStream[T_co]:
37
+ return self
38
+
39
+ async def __anext__(self) -> T_co:
40
+ try:
41
+ return await self.receive()
42
+ except EndOfStream:
43
+ raise StopAsyncIteration from None
44
+
45
+ @abstractmethod
46
+ async def receive(self) -> T_co:
47
+ """
48
+ Receive the next item.
49
+
50
+ :raises ~anyio.ClosedResourceError: if the receive stream has been explicitly
51
+ closed
52
+ :raises ~anyio.EndOfStream: if this stream has been closed from the other end
53
+ :raises ~anyio.BrokenResourceError: if this stream has been rendered unusable
54
+ due to external causes
55
+ """
56
+
57
+
58
+ class UnreliableObjectSendStream(
59
+ Generic[T_contra], AsyncResource, TypedAttributeProvider
60
+ ):
61
+ """
62
+ An interface for sending objects.
63
+
64
+ This interface makes no guarantees that the messages sent will reach the
65
+ recipient(s) in the same order in which they were sent, or at all.
66
+ """
67
+
68
+ @abstractmethod
69
+ async def send(self, item: T_contra) -> None:
70
+ """
71
+ Send an item to the peer(s).
72
+
73
+ :param item: the item to send
74
+ :raises ~anyio.ClosedResourceError: if the send stream has been explicitly
75
+ closed
76
+ :raises ~anyio.BrokenResourceError: if this stream has been rendered unusable
77
+ due to external causes
78
+ """
79
+
80
+
81
+ class UnreliableObjectStream(
82
+ UnreliableObjectReceiveStream[T_Item], UnreliableObjectSendStream[T_Item]
83
+ ):
84
+ """
85
+ A bidirectional message stream which does not guarantee the order or reliability of
86
+ message delivery.
87
+ """
88
+
89
+
90
+ class ObjectReceiveStream(UnreliableObjectReceiveStream[T_co]):
91
+ """
92
+ A receive message stream which guarantees that messages are received in the same
93
+ order in which they were sent, and that no messages are missed.
94
+ """
95
+
96
+
97
+ class ObjectSendStream(UnreliableObjectSendStream[T_contra]):
98
+ """
99
+ A send message stream which guarantees that messages are delivered in the same order
100
+ in which they were sent, without missing any messages in the middle.
101
+ """
102
+
103
+
104
+ class ObjectStream(
105
+ ObjectReceiveStream[T_Item],
106
+ ObjectSendStream[T_Item],
107
+ UnreliableObjectStream[T_Item],
108
+ ):
109
+ """
110
+ A bidirectional message stream which guarantees the order and reliability of message
111
+ delivery.
112
+ """
113
+
114
+ @abstractmethod
115
+ async def send_eof(self) -> None:
116
+ """
117
+ Send an end-of-file indication to the peer.
118
+
119
+ You should not try to send any further data to this stream after calling this
120
+ method. This method is idempotent (does nothing on successive calls).
121
+ """
122
+
123
+
124
+ class ByteReceiveStream(AsyncResource, TypedAttributeProvider):
125
+ """
126
+ An interface for receiving bytes from a single peer.
127
+
128
+ Iterating this byte stream will yield a byte string of arbitrary length, but no more
129
+ than 65536 bytes.
130
+ """
131
+
132
+ def __aiter__(self) -> ByteReceiveStream:
133
+ return self
134
+
135
+ async def __anext__(self) -> bytes:
136
+ try:
137
+ return await self.receive()
138
+ except EndOfStream:
139
+ raise StopAsyncIteration from None
140
+
141
+ @abstractmethod
142
+ async def receive(self, max_bytes: int = 65536) -> bytes:
143
+ """
144
+ Receive at most ``max_bytes`` bytes from the peer.
145
+
146
+ .. note:: Implementers of this interface should not return an empty
147
+ :class:`bytes` object, and users should ignore them.
148
+
149
+ :param max_bytes: maximum number of bytes to receive
150
+ :return: the received bytes
151
+ :raises ~anyio.EndOfStream: if this stream has been closed from the other end
152
+ """
153
+
154
+
155
+ class ByteSendStream(AsyncResource, TypedAttributeProvider):
156
+ """An interface for sending bytes to a single peer."""
157
+
158
+ @abstractmethod
159
+ async def send(self, item: bytes) -> None:
160
+ """
161
+ Send the given bytes to the peer.
162
+
163
+ :param item: the bytes to send
164
+ """
165
+
166
+
167
+ class ByteStream(ByteReceiveStream, ByteSendStream):
168
+ """A bidirectional byte stream."""
169
+
170
+ @abstractmethod
171
+ async def send_eof(self) -> None:
172
+ """
173
+ Send an end-of-file indication to the peer.
174
+
175
+ You should not try to send any further data to this stream after calling this
176
+ method. This method is idempotent (does nothing on successive calls).
177
+ """
178
+
179
+
180
+ #: Type alias for all unreliable bytes-oriented receive streams.
181
+ AnyUnreliableByteReceiveStream: TypeAlias = Union[
182
+ UnreliableObjectReceiveStream[bytes], ByteReceiveStream
183
+ ]
184
+ #: Type alias for all unreliable bytes-oriented send streams.
185
+ AnyUnreliableByteSendStream: TypeAlias = Union[
186
+ UnreliableObjectSendStream[bytes], ByteSendStream
187
+ ]
188
+ #: Type alias for all unreliable bytes-oriented streams.
189
+ AnyUnreliableByteStream: TypeAlias = Union[UnreliableObjectStream[bytes], ByteStream]
190
+ #: Type alias for all bytes-oriented receive streams.
191
+ AnyByteReceiveStream: TypeAlias = Union[ObjectReceiveStream[bytes], ByteReceiveStream]
192
+ #: Type alias for all bytes-oriented send streams.
193
+ AnyByteSendStream: TypeAlias = Union[ObjectSendStream[bytes], ByteSendStream]
194
+ #: Type alias for all bytes-oriented streams.
195
+ AnyByteStream: TypeAlias = Union[ObjectStream[bytes], ByteStream]
196
+
197
+
198
+ class Listener(Generic[T_co], AsyncResource, TypedAttributeProvider):
199
+ """An interface for objects that let you accept incoming connections."""
200
+
201
+ @abstractmethod
202
+ async def serve(
203
+ self, handler: Callable[[T_co], Any], task_group: TaskGroup | None = None
204
+ ) -> None:
205
+ """
206
+ Accept incoming connections as they come in and start tasks to handle them.
207
+
208
+ :param handler: a callable that will be used to handle each accepted connection
209
+ :param task_group: the task group that will be used to start tasks for handling
210
+ each accepted connection (if omitted, an ad-hoc task group will be created)
211
+ """
212
+
213
+
214
+ class ObjectStreamConnectable(Generic[T_co], metaclass=ABCMeta):
215
+ @abstractmethod
216
+ async def connect(self) -> ObjectStream[T_co]:
217
+ """
218
+ Connect to the remote endpoint.
219
+
220
+ :return: an object stream connected to the remote end
221
+ :raises ConnectionFailed: if the connection fails
222
+ """
223
+
224
+
225
+ class ByteStreamConnectable(metaclass=ABCMeta):
226
+ @abstractmethod
227
+ async def connect(self) -> ByteStream:
228
+ """
229
+ Connect to the remote endpoint.
230
+
231
+ :return: a bytestream connected to the remote end
232
+ :raises ConnectionFailed: if the connection fails
233
+ """
234
+
235
+
236
+ #: Type alias for all connectables returning bytestreams or bytes-oriented object streams
237
+ AnyByteStreamConnectable: TypeAlias = Union[
238
+ ObjectStreamConnectable[bytes], ByteStreamConnectable
239
+ ]
miniconda3/lib/python3.13/site-packages/anyio/abc/_subprocesses.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from abc import abstractmethod
4
+ from signal import Signals
5
+
6
+ from ._resources import AsyncResource
7
+ from ._streams import ByteReceiveStream, ByteSendStream
8
+
9
+
10
+ class Process(AsyncResource):
11
+ """An asynchronous version of :class:`subprocess.Popen`."""
12
+
13
+ @abstractmethod
14
+ async def wait(self) -> int:
15
+ """
16
+ Wait until the process exits.
17
+
18
+ :return: the exit code of the process
19
+ """
20
+
21
+ @abstractmethod
22
+ def terminate(self) -> None:
23
+ """
24
+ Terminates the process, gracefully if possible.
25
+
26
+ On Windows, this calls ``TerminateProcess()``.
27
+ On POSIX systems, this sends ``SIGTERM`` to the process.
28
+
29
+ .. seealso:: :meth:`subprocess.Popen.terminate`
30
+ """
31
+
32
+ @abstractmethod
33
+ def kill(self) -> None:
34
+ """
35
+ Kills the process.
36
+
37
+ On Windows, this calls ``TerminateProcess()``.
38
+ On POSIX systems, this sends ``SIGKILL`` to the process.
39
+
40
+ .. seealso:: :meth:`subprocess.Popen.kill`
41
+ """
42
+
43
+ @abstractmethod
44
+ def send_signal(self, signal: Signals) -> None:
45
+ """
46
+ Send a signal to the subprocess.
47
+
48
+ .. seealso:: :meth:`subprocess.Popen.send_signal`
49
+
50
+ :param signal: the signal number (e.g. :data:`signal.SIGHUP`)
51
+ """
52
+
53
+ @property
54
+ @abstractmethod
55
+ def pid(self) -> int:
56
+ """The process ID of the process."""
57
+
58
+ @property
59
+ @abstractmethod
60
+ def returncode(self) -> int | None:
61
+ """
62
+ The return code of the process. If the process has not yet terminated, this will
63
+ be ``None``.
64
+ """
65
+
66
+ @property
67
+ @abstractmethod
68
+ def stdin(self) -> ByteSendStream | None:
69
+ """The stream for the standard input of the process."""
70
+
71
+ @property
72
+ @abstractmethod
73
+ def stdout(self) -> ByteReceiveStream | None:
74
+ """The stream for the standard output of the process."""
75
+
76
+ @property
77
+ @abstractmethod
78
+ def stderr(self) -> ByteReceiveStream | None:
79
+ """The stream for the standard error output of the process."""
miniconda3/lib/python3.13/site-packages/anyio/abc/_tasks.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ from abc import ABCMeta, abstractmethod
5
+ from collections.abc import Awaitable, Callable
6
+ from types import TracebackType
7
+ from typing import TYPE_CHECKING, Any, Protocol, TypeVar, overload
8
+
9
+ if sys.version_info >= (3, 11):
10
+ from typing import TypeVarTuple, Unpack
11
+ else:
12
+ from typing_extensions import TypeVarTuple, Unpack
13
+
14
+ if TYPE_CHECKING:
15
+ from .._core._tasks import CancelScope
16
+
17
+ T_Retval = TypeVar("T_Retval")
18
+ T_contra = TypeVar("T_contra", contravariant=True)
19
+ PosArgsT = TypeVarTuple("PosArgsT")
20
+
21
+
22
+ class TaskStatus(Protocol[T_contra]):
23
+ @overload
24
+ def started(self: TaskStatus[None]) -> None: ...
25
+
26
+ @overload
27
+ def started(self, value: T_contra) -> None: ...
28
+
29
+ def started(self, value: T_contra | None = None) -> None:
30
+ """
31
+ Signal that the task has started.
32
+
33
+ :param value: object passed back to the starter of the task
34
+ """
35
+
36
+
37
+ class TaskGroup(metaclass=ABCMeta):
38
+ """
39
+ Groups several asynchronous tasks together.
40
+
41
+ :ivar cancel_scope: the cancel scope inherited by all child tasks
42
+ :vartype cancel_scope: CancelScope
43
+
44
+ .. note:: On asyncio, support for eager task factories is considered to be
45
+ **experimental**. In particular, they don't follow the usual semantics of new
46
+ tasks being scheduled on the next iteration of the event loop, and may thus
47
+ cause unexpected behavior in code that wasn't written with such semantics in
48
+ mind.
49
+ """
50
+
51
+ cancel_scope: CancelScope
52
+
53
+ @abstractmethod
54
+ def start_soon(
55
+ self,
56
+ func: Callable[[Unpack[PosArgsT]], Awaitable[Any]],
57
+ *args: Unpack[PosArgsT],
58
+ name: object = None,
59
+ ) -> None:
60
+ """
61
+ Start a new task in this task group.
62
+
63
+ :param func: a coroutine function
64
+ :param args: positional arguments to call the function with
65
+ :param name: name of the task, for the purposes of introspection and debugging
66
+
67
+ .. versionadded:: 3.0
68
+ """
69
+
70
+ @abstractmethod
71
+ async def start(
72
+ self,
73
+ func: Callable[..., Awaitable[Any]],
74
+ *args: object,
75
+ name: object = None,
76
+ ) -> Any:
77
+ """
78
+ Start a new task and wait until it signals for readiness.
79
+
80
+ The target callable must accept a keyword argument ``task_status`` (of type
81
+ :class:`TaskStatus`). Awaiting on this method will return whatever was passed to
82
+ ``task_status.started()`` (``None`` by default).
83
+
84
+ .. note:: The :class:`TaskStatus` class is generic, and the type argument should
85
+ indicate the type of the value that will be passed to
86
+ ``task_status.started()``.
87
+
88
+ :param func: a coroutine function that accepts the ``task_status`` keyword
89
+ argument
90
+ :param args: positional arguments to call the function with
91
+ :param name: an optional name for the task, for introspection and debugging
92
+ :return: the value passed to ``task_status.started()``
93
+ :raises RuntimeError: if the task finishes without calling
94
+ ``task_status.started()``
95
+
96
+ .. seealso:: :ref:`start_initialize`
97
+
98
+ .. versionadded:: 3.0
99
+ """
100
+
101
+ @abstractmethod
102
+ async def __aenter__(self) -> TaskGroup:
103
+ """Enter the task group context and allow starting new tasks."""
104
+
105
+ @abstractmethod
106
+ async def __aexit__(
107
+ self,
108
+ exc_type: type[BaseException] | None,
109
+ exc_val: BaseException | None,
110
+ exc_tb: TracebackType | None,
111
+ ) -> bool:
112
+ """Exit the task group context waiting for all tasks to finish."""
miniconda3/lib/python3.13/site-packages/anyio/abc/_testing.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import types
4
+ from abc import ABCMeta, abstractmethod
5
+ from collections.abc import AsyncGenerator, Callable, Coroutine, Iterable
6
+ from typing import Any, TypeVar
7
+
8
+ _T = TypeVar("_T")
9
+
10
+
11
+ class TestRunner(metaclass=ABCMeta):
12
+ """
13
+ Encapsulates a running event loop. Every call made through this object will use the
14
+ same event loop.
15
+ """
16
+
17
+ def __enter__(self) -> TestRunner:
18
+ return self
19
+
20
+ @abstractmethod
21
+ def __exit__(
22
+ self,
23
+ exc_type: type[BaseException] | None,
24
+ exc_val: BaseException | None,
25
+ exc_tb: types.TracebackType | None,
26
+ ) -> bool | None: ...
27
+
28
+ @abstractmethod
29
+ def run_asyncgen_fixture(
30
+ self,
31
+ fixture_func: Callable[..., AsyncGenerator[_T, Any]],
32
+ kwargs: dict[str, Any],
33
+ ) -> Iterable[_T]:
34
+ """
35
+ Run an async generator fixture.
36
+
37
+ :param fixture_func: the fixture function
38
+ :param kwargs: keyword arguments to call the fixture function with
39
+ :return: an iterator yielding the value yielded from the async generator
40
+ """
41
+
42
+ @abstractmethod
43
+ def run_fixture(
44
+ self,
45
+ fixture_func: Callable[..., Coroutine[Any, Any, _T]],
46
+ kwargs: dict[str, Any],
47
+ ) -> _T:
48
+ """
49
+ Run an async fixture.
50
+
51
+ :param fixture_func: the fixture function
52
+ :param kwargs: keyword arguments to call the fixture function with
53
+ :return: the return value of the fixture function
54
+ """
55
+
56
+ @abstractmethod
57
+ def run_test(
58
+ self, test_func: Callable[..., Coroutine[Any, Any, Any]], kwargs: dict[str, Any]
59
+ ) -> None:
60
+ """
61
+ Run an async test function.
62
+
63
+ :param test_func: the test function
64
+ :param kwargs: keyword arguments to call the test function with
65
+ """
miniconda3/lib/python3.13/site-packages/anyio/streams/__init__.py ADDED
File without changes
miniconda3/lib/python3.13/site-packages/anyio/streams/buffered.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ from collections.abc import Callable, Iterable, Mapping
5
+ from dataclasses import dataclass, field
6
+ from typing import Any, SupportsIndex
7
+
8
+ from .. import ClosedResourceError, DelimiterNotFound, EndOfStream, IncompleteRead
9
+ from ..abc import (
10
+ AnyByteReceiveStream,
11
+ AnyByteStream,
12
+ AnyByteStreamConnectable,
13
+ ByteReceiveStream,
14
+ ByteStream,
15
+ ByteStreamConnectable,
16
+ )
17
+
18
+ if sys.version_info >= (3, 12):
19
+ from typing import override
20
+ else:
21
+ from typing_extensions import override
22
+
23
+
24
+ @dataclass(eq=False)
25
+ class BufferedByteReceiveStream(ByteReceiveStream):
26
+ """
27
+ Wraps any bytes-based receive stream and uses a buffer to provide sophisticated
28
+ receiving capabilities in the form of a byte stream.
29
+ """
30
+
31
+ receive_stream: AnyByteReceiveStream
32
+ _buffer: bytearray = field(init=False, default_factory=bytearray)
33
+ _closed: bool = field(init=False, default=False)
34
+
35
+ async def aclose(self) -> None:
36
+ await self.receive_stream.aclose()
37
+ self._closed = True
38
+
39
+ @property
40
+ def buffer(self) -> bytes:
41
+ """The bytes currently in the buffer."""
42
+ return bytes(self._buffer)
43
+
44
+ @property
45
+ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
46
+ return self.receive_stream.extra_attributes
47
+
48
+ def feed_data(self, data: Iterable[SupportsIndex], /) -> None:
49
+ """
50
+ Append data directly into the buffer.
51
+
52
+ Any data in the buffer will be consumed by receive operations before receiving
53
+ anything from the wrapped stream.
54
+
55
+ :param data: the data to append to the buffer (can be bytes or anything else
56
+ that supports ``__index__()``)
57
+
58
+ """
59
+ self._buffer.extend(data)
60
+
61
+ async def receive(self, max_bytes: int = 65536) -> bytes:
62
+ if self._closed:
63
+ raise ClosedResourceError
64
+
65
+ if self._buffer:
66
+ chunk = bytes(self._buffer[:max_bytes])
67
+ del self._buffer[:max_bytes]
68
+ return chunk
69
+ elif isinstance(self.receive_stream, ByteReceiveStream):
70
+ return await self.receive_stream.receive(max_bytes)
71
+ else:
72
+ # With a bytes-oriented object stream, we need to handle any surplus bytes
73
+ # we get from the receive() call
74
+ chunk = await self.receive_stream.receive()
75
+ if len(chunk) > max_bytes:
76
+ # Save the surplus bytes in the buffer
77
+ self._buffer.extend(chunk[max_bytes:])
78
+ return chunk[:max_bytes]
79
+ else:
80
+ return chunk
81
+
82
+ async def receive_exactly(self, nbytes: int) -> bytes:
83
+ """
84
+ Read exactly the given amount of bytes from the stream.
85
+
86
+ :param nbytes: the number of bytes to read
87
+ :return: the bytes read
88
+ :raises ~anyio.IncompleteRead: if the stream was closed before the requested
89
+ amount of bytes could be read from the stream
90
+
91
+ """
92
+ while True:
93
+ remaining = nbytes - len(self._buffer)
94
+ if remaining <= 0:
95
+ retval = self._buffer[:nbytes]
96
+ del self._buffer[:nbytes]
97
+ return bytes(retval)
98
+
99
+ try:
100
+ if isinstance(self.receive_stream, ByteReceiveStream):
101
+ chunk = await self.receive_stream.receive(remaining)
102
+ else:
103
+ chunk = await self.receive_stream.receive()
104
+ except EndOfStream as exc:
105
+ raise IncompleteRead from exc
106
+
107
+ self._buffer.extend(chunk)
108
+
109
+ async def receive_until(self, delimiter: bytes, max_bytes: int) -> bytes:
110
+ """
111
+ Read from the stream until the delimiter is found or max_bytes have been read.
112
+
113
+ :param delimiter: the marker to look for in the stream
114
+ :param max_bytes: maximum number of bytes that will be read before raising
115
+ :exc:`~anyio.DelimiterNotFound`
116
+ :return: the bytes read (not including the delimiter)
117
+ :raises ~anyio.IncompleteRead: if the stream was closed before the delimiter
118
+ was found
119
+ :raises ~anyio.DelimiterNotFound: if the delimiter is not found within the
120
+ bytes read up to the maximum allowed
121
+
122
+ """
123
+ delimiter_size = len(delimiter)
124
+ offset = 0
125
+ while True:
126
+ # Check if the delimiter can be found in the current buffer
127
+ index = self._buffer.find(delimiter, offset)
128
+ if index >= 0:
129
+ found = self._buffer[:index]
130
+ del self._buffer[: index + len(delimiter) :]
131
+ return bytes(found)
132
+
133
+ # Check if the buffer is already at or over the limit
134
+ if len(self._buffer) >= max_bytes:
135
+ raise DelimiterNotFound(max_bytes)
136
+
137
+ # Read more data into the buffer from the socket
138
+ try:
139
+ data = await self.receive_stream.receive()
140
+ except EndOfStream as exc:
141
+ raise IncompleteRead from exc
142
+
143
+ # Move the offset forward and add the new data to the buffer
144
+ offset = max(len(self._buffer) - delimiter_size + 1, 0)
145
+ self._buffer.extend(data)
146
+
147
+
148
+ class BufferedByteStream(BufferedByteReceiveStream, ByteStream):
149
+ """
150
+ A full-duplex variant of :class:`BufferedByteReceiveStream`. All writes are passed
151
+ through to the wrapped stream as-is.
152
+ """
153
+
154
+ def __init__(self, stream: AnyByteStream):
155
+ """
156
+ :param stream: the stream to be wrapped
157
+
158
+ """
159
+ super().__init__(stream)
160
+ self._stream = stream
161
+
162
+ @override
163
+ async def send_eof(self) -> None:
164
+ await self._stream.send_eof()
165
+
166
+ @override
167
+ async def send(self, item: bytes) -> None:
168
+ await self._stream.send(item)
169
+
170
+
171
+ class BufferedConnectable(ByteStreamConnectable):
172
+ def __init__(self, connectable: AnyByteStreamConnectable):
173
+ """
174
+ :param connectable: the connectable to wrap
175
+
176
+ """
177
+ self.connectable = connectable
178
+
179
+ @override
180
+ async def connect(self) -> BufferedByteStream:
181
+ stream = await self.connectable.connect()
182
+ return BufferedByteStream(stream)
miniconda3/lib/python3.13/site-packages/anyio/streams/file.py ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Callable, Mapping
4
+ from io import SEEK_SET, UnsupportedOperation
5
+ from os import PathLike
6
+ from pathlib import Path
7
+ from typing import Any, BinaryIO, cast
8
+
9
+ from .. import (
10
+ BrokenResourceError,
11
+ ClosedResourceError,
12
+ EndOfStream,
13
+ TypedAttributeSet,
14
+ to_thread,
15
+ typed_attribute,
16
+ )
17
+ from ..abc import ByteReceiveStream, ByteSendStream
18
+
19
+
20
+ class FileStreamAttribute(TypedAttributeSet):
21
+ #: the open file descriptor
22
+ file: BinaryIO = typed_attribute()
23
+ #: the path of the file on the file system, if available (file must be a real file)
24
+ path: Path = typed_attribute()
25
+ #: the file number, if available (file must be a real file or a TTY)
26
+ fileno: int = typed_attribute()
27
+
28
+
29
+ class _BaseFileStream:
30
+ def __init__(self, file: BinaryIO):
31
+ self._file = file
32
+
33
+ async def aclose(self) -> None:
34
+ await to_thread.run_sync(self._file.close)
35
+
36
+ @property
37
+ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
38
+ attributes: dict[Any, Callable[[], Any]] = {
39
+ FileStreamAttribute.file: lambda: self._file,
40
+ }
41
+
42
+ if hasattr(self._file, "name"):
43
+ attributes[FileStreamAttribute.path] = lambda: Path(self._file.name)
44
+
45
+ try:
46
+ self._file.fileno()
47
+ except UnsupportedOperation:
48
+ pass
49
+ else:
50
+ attributes[FileStreamAttribute.fileno] = lambda: self._file.fileno()
51
+
52
+ return attributes
53
+
54
+
55
+ class FileReadStream(_BaseFileStream, ByteReceiveStream):
56
+ """
57
+ A byte stream that reads from a file in the file system.
58
+
59
+ :param file: a file that has been opened for reading in binary mode
60
+
61
+ .. versionadded:: 3.0
62
+ """
63
+
64
+ @classmethod
65
+ async def from_path(cls, path: str | PathLike[str]) -> FileReadStream:
66
+ """
67
+ Create a file read stream by opening the given file.
68
+
69
+ :param path: path of the file to read from
70
+
71
+ """
72
+ file = await to_thread.run_sync(Path(path).open, "rb")
73
+ return cls(cast(BinaryIO, file))
74
+
75
+ async def receive(self, max_bytes: int = 65536) -> bytes:
76
+ try:
77
+ data = await to_thread.run_sync(self._file.read, max_bytes)
78
+ except ValueError:
79
+ raise ClosedResourceError from None
80
+ except OSError as exc:
81
+ raise BrokenResourceError from exc
82
+
83
+ if data:
84
+ return data
85
+ else:
86
+ raise EndOfStream
87
+
88
+ async def seek(self, position: int, whence: int = SEEK_SET) -> int:
89
+ """
90
+ Seek the file to the given position.
91
+
92
+ .. seealso:: :meth:`io.IOBase.seek`
93
+
94
+ .. note:: Not all file descriptors are seekable.
95
+
96
+ :param position: position to seek the file to
97
+ :param whence: controls how ``position`` is interpreted
98
+ :return: the new absolute position
99
+ :raises OSError: if the file is not seekable
100
+
101
+ """
102
+ return await to_thread.run_sync(self._file.seek, position, whence)
103
+
104
+ async def tell(self) -> int:
105
+ """
106
+ Return the current stream position.
107
+
108
+ .. note:: Not all file descriptors are seekable.
109
+
110
+ :return: the current absolute position
111
+ :raises OSError: if the file is not seekable
112
+
113
+ """
114
+ return await to_thread.run_sync(self._file.tell)
115
+
116
+
117
+ class FileWriteStream(_BaseFileStream, ByteSendStream):
118
+ """
119
+ A byte stream that writes to a file in the file system.
120
+
121
+ :param file: a file that has been opened for writing in binary mode
122
+
123
+ .. versionadded:: 3.0
124
+ """
125
+
126
+ @classmethod
127
+ async def from_path(
128
+ cls, path: str | PathLike[str], append: bool = False
129
+ ) -> FileWriteStream:
130
+ """
131
+ Create a file write stream by opening the given file for writing.
132
+
133
+ :param path: path of the file to write to
134
+ :param append: if ``True``, open the file for appending; if ``False``, any
135
+ existing file at the given path will be truncated
136
+
137
+ """
138
+ mode = "ab" if append else "wb"
139
+ file = await to_thread.run_sync(Path(path).open, mode)
140
+ return cls(cast(BinaryIO, file))
141
+
142
+ async def send(self, item: bytes) -> None:
143
+ try:
144
+ await to_thread.run_sync(self._file.write, item)
145
+ except ValueError:
146
+ raise ClosedResourceError from None
147
+ except OSError as exc:
148
+ raise BrokenResourceError from exc
miniconda3/lib/python3.13/site-packages/anyio/streams/memory.py ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import warnings
4
+ from collections import OrderedDict, deque
5
+ from dataclasses import dataclass, field
6
+ from types import TracebackType
7
+ from typing import Generic, NamedTuple, TypeVar
8
+
9
+ from .. import (
10
+ BrokenResourceError,
11
+ ClosedResourceError,
12
+ EndOfStream,
13
+ WouldBlock,
14
+ )
15
+ from .._core._testing import TaskInfo, get_current_task
16
+ from ..abc import Event, ObjectReceiveStream, ObjectSendStream
17
+ from ..lowlevel import checkpoint
18
+
19
+ T_Item = TypeVar("T_Item")
20
+ T_co = TypeVar("T_co", covariant=True)
21
+ T_contra = TypeVar("T_contra", contravariant=True)
22
+
23
+
24
+ class MemoryObjectStreamStatistics(NamedTuple):
25
+ current_buffer_used: int #: number of items stored in the buffer
26
+ #: maximum number of items that can be stored on this stream (or :data:`math.inf`)
27
+ max_buffer_size: float
28
+ open_send_streams: int #: number of unclosed clones of the send stream
29
+ open_receive_streams: int #: number of unclosed clones of the receive stream
30
+ #: number of tasks blocked on :meth:`MemoryObjectSendStream.send`
31
+ tasks_waiting_send: int
32
+ #: number of tasks blocked on :meth:`MemoryObjectReceiveStream.receive`
33
+ tasks_waiting_receive: int
34
+
35
+
36
+ @dataclass(eq=False)
37
+ class MemoryObjectItemReceiver(Generic[T_Item]):
38
+ task_info: TaskInfo = field(init=False, default_factory=get_current_task)
39
+ item: T_Item = field(init=False)
40
+
41
+ def __repr__(self) -> str:
42
+ # When item is not defined, we get following error with default __repr__:
43
+ # AttributeError: 'MemoryObjectItemReceiver' object has no attribute 'item'
44
+ item = getattr(self, "item", None)
45
+ return f"{self.__class__.__name__}(task_info={self.task_info}, item={item!r})"
46
+
47
+
48
+ @dataclass(eq=False)
49
+ class MemoryObjectStreamState(Generic[T_Item]):
50
+ max_buffer_size: float = field()
51
+ buffer: deque[T_Item] = field(init=False, default_factory=deque)
52
+ open_send_channels: int = field(init=False, default=0)
53
+ open_receive_channels: int = field(init=False, default=0)
54
+ waiting_receivers: OrderedDict[Event, MemoryObjectItemReceiver[T_Item]] = field(
55
+ init=False, default_factory=OrderedDict
56
+ )
57
+ waiting_senders: OrderedDict[Event, T_Item] = field(
58
+ init=False, default_factory=OrderedDict
59
+ )
60
+
61
+ def statistics(self) -> MemoryObjectStreamStatistics:
62
+ return MemoryObjectStreamStatistics(
63
+ len(self.buffer),
64
+ self.max_buffer_size,
65
+ self.open_send_channels,
66
+ self.open_receive_channels,
67
+ len(self.waiting_senders),
68
+ len(self.waiting_receivers),
69
+ )
70
+
71
+
72
+ @dataclass(eq=False)
73
+ class MemoryObjectReceiveStream(Generic[T_co], ObjectReceiveStream[T_co]):
74
+ _state: MemoryObjectStreamState[T_co]
75
+ _closed: bool = field(init=False, default=False)
76
+
77
+ def __post_init__(self) -> None:
78
+ self._state.open_receive_channels += 1
79
+
80
+ def receive_nowait(self) -> T_co:
81
+ """
82
+ Receive the next item if it can be done without waiting.
83
+
84
+ :return: the received item
85
+ :raises ~anyio.ClosedResourceError: if this send stream has been closed
86
+ :raises ~anyio.EndOfStream: if the buffer is empty and this stream has been
87
+ closed from the sending end
88
+ :raises ~anyio.WouldBlock: if there are no items in the buffer and no tasks
89
+ waiting to send
90
+
91
+ """
92
+ if self._closed:
93
+ raise ClosedResourceError
94
+
95
+ if self._state.waiting_senders:
96
+ # Get the item from the next sender
97
+ send_event, item = self._state.waiting_senders.popitem(last=False)
98
+ self._state.buffer.append(item)
99
+ send_event.set()
100
+
101
+ if self._state.buffer:
102
+ return self._state.buffer.popleft()
103
+ elif not self._state.open_send_channels:
104
+ raise EndOfStream
105
+
106
+ raise WouldBlock
107
+
108
+ async def receive(self) -> T_co:
109
+ await checkpoint()
110
+ try:
111
+ return self.receive_nowait()
112
+ except WouldBlock:
113
+ # Add ourselves in the queue
114
+ receive_event = Event()
115
+ receiver = MemoryObjectItemReceiver[T_co]()
116
+ self._state.waiting_receivers[receive_event] = receiver
117
+
118
+ try:
119
+ await receive_event.wait()
120
+ finally:
121
+ self._state.waiting_receivers.pop(receive_event, None)
122
+
123
+ try:
124
+ return receiver.item
125
+ except AttributeError:
126
+ raise EndOfStream from None
127
+
128
+ def clone(self) -> MemoryObjectReceiveStream[T_co]:
129
+ """
130
+ Create a clone of this receive stream.
131
+
132
+ Each clone can be closed separately. Only when all clones have been closed will
133
+ the receiving end of the memory stream be considered closed by the sending ends.
134
+
135
+ :return: the cloned stream
136
+
137
+ """
138
+ if self._closed:
139
+ raise ClosedResourceError
140
+
141
+ return MemoryObjectReceiveStream(_state=self._state)
142
+
143
+ def close(self) -> None:
144
+ """
145
+ Close the stream.
146
+
147
+ This works the exact same way as :meth:`aclose`, but is provided as a special
148
+ case for the benefit of synchronous callbacks.
149
+
150
+ """
151
+ if not self._closed:
152
+ self._closed = True
153
+ self._state.open_receive_channels -= 1
154
+ if self._state.open_receive_channels == 0:
155
+ send_events = list(self._state.waiting_senders.keys())
156
+ for event in send_events:
157
+ event.set()
158
+
159
+ async def aclose(self) -> None:
160
+ self.close()
161
+
162
+ def statistics(self) -> MemoryObjectStreamStatistics:
163
+ """
164
+ Return statistics about the current state of this stream.
165
+
166
+ .. versionadded:: 3.0
167
+ """
168
+ return self._state.statistics()
169
+
170
+ def __enter__(self) -> MemoryObjectReceiveStream[T_co]:
171
+ return self
172
+
173
+ def __exit__(
174
+ self,
175
+ exc_type: type[BaseException] | None,
176
+ exc_val: BaseException | None,
177
+ exc_tb: TracebackType | None,
178
+ ) -> None:
179
+ self.close()
180
+
181
+ def __del__(self) -> None:
182
+ if not self._closed:
183
+ warnings.warn(
184
+ f"Unclosed <{self.__class__.__name__} at {id(self):x}>",
185
+ ResourceWarning,
186
+ stacklevel=1,
187
+ source=self,
188
+ )
189
+
190
+
191
+ @dataclass(eq=False)
192
+ class MemoryObjectSendStream(Generic[T_contra], ObjectSendStream[T_contra]):
193
+ _state: MemoryObjectStreamState[T_contra]
194
+ _closed: bool = field(init=False, default=False)
195
+
196
+ def __post_init__(self) -> None:
197
+ self._state.open_send_channels += 1
198
+
199
+ def send_nowait(self, item: T_contra) -> None:
200
+ """
201
+ Send an item immediately if it can be done without waiting.
202
+
203
+ :param item: the item to send
204
+ :raises ~anyio.ClosedResourceError: if this send stream has been closed
205
+ :raises ~anyio.BrokenResourceError: if the stream has been closed from the
206
+ receiving end
207
+ :raises ~anyio.WouldBlock: if the buffer is full and there are no tasks waiting
208
+ to receive
209
+
210
+ """
211
+ if self._closed:
212
+ raise ClosedResourceError
213
+ if not self._state.open_receive_channels:
214
+ raise BrokenResourceError
215
+
216
+ while self._state.waiting_receivers:
217
+ receive_event, receiver = self._state.waiting_receivers.popitem(last=False)
218
+ if not receiver.task_info.has_pending_cancellation():
219
+ receiver.item = item
220
+ receive_event.set()
221
+ return
222
+
223
+ if len(self._state.buffer) < self._state.max_buffer_size:
224
+ self._state.buffer.append(item)
225
+ else:
226
+ raise WouldBlock
227
+
228
+ async def send(self, item: T_contra) -> None:
229
+ """
230
+ Send an item to the stream.
231
+
232
+ If the buffer is full, this method blocks until there is again room in the
233
+ buffer or the item can be sent directly to a receiver.
234
+
235
+ :param item: the item to send
236
+ :raises ~anyio.ClosedResourceError: if this send stream has been closed
237
+ :raises ~anyio.BrokenResourceError: if the stream has been closed from the
238
+ receiving end
239
+
240
+ """
241
+ await checkpoint()
242
+ try:
243
+ self.send_nowait(item)
244
+ except WouldBlock:
245
+ # Wait until there's someone on the receiving end
246
+ send_event = Event()
247
+ self._state.waiting_senders[send_event] = item
248
+ try:
249
+ await send_event.wait()
250
+ except BaseException:
251
+ self._state.waiting_senders.pop(send_event, None)
252
+ raise
253
+
254
+ if send_event in self._state.waiting_senders:
255
+ del self._state.waiting_senders[send_event]
256
+ raise BrokenResourceError from None
257
+
258
+ def clone(self) -> MemoryObjectSendStream[T_contra]:
259
+ """
260
+ Create a clone of this send stream.
261
+
262
+ Each clone can be closed separately. Only when all clones have been closed will
263
+ the sending end of the memory stream be considered closed by the receiving ends.
264
+
265
+ :return: the cloned stream
266
+
267
+ """
268
+ if self._closed:
269
+ raise ClosedResourceError
270
+
271
+ return MemoryObjectSendStream(_state=self._state)
272
+
273
+ def close(self) -> None:
274
+ """
275
+ Close the stream.
276
+
277
+ This works the exact same way as :meth:`aclose`, but is provided as a special
278
+ case for the benefit of synchronous callbacks.
279
+
280
+ """
281
+ if not self._closed:
282
+ self._closed = True
283
+ self._state.open_send_channels -= 1
284
+ if self._state.open_send_channels == 0:
285
+ receive_events = list(self._state.waiting_receivers.keys())
286
+ self._state.waiting_receivers.clear()
287
+ for event in receive_events:
288
+ event.set()
289
+
290
+ async def aclose(self) -> None:
291
+ self.close()
292
+
293
+ def statistics(self) -> MemoryObjectStreamStatistics:
294
+ """
295
+ Return statistics about the current state of this stream.
296
+
297
+ .. versionadded:: 3.0
298
+ """
299
+ return self._state.statistics()
300
+
301
+ def __enter__(self) -> MemoryObjectSendStream[T_contra]:
302
+ return self
303
+
304
+ def __exit__(
305
+ self,
306
+ exc_type: type[BaseException] | None,
307
+ exc_val: BaseException | None,
308
+ exc_tb: TracebackType | None,
309
+ ) -> None:
310
+ self.close()
311
+
312
+ def __del__(self) -> None:
313
+ if not self._closed:
314
+ warnings.warn(
315
+ f"Unclosed <{self.__class__.__name__} at {id(self):x}>",
316
+ ResourceWarning,
317
+ stacklevel=1,
318
+ source=self,
319
+ )
miniconda3/lib/python3.13/site-packages/anyio/streams/stapled.py ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Callable, Mapping, Sequence
4
+ from dataclasses import dataclass
5
+ from typing import Any, Generic, TypeVar
6
+
7
+ from ..abc import (
8
+ ByteReceiveStream,
9
+ ByteSendStream,
10
+ ByteStream,
11
+ Listener,
12
+ ObjectReceiveStream,
13
+ ObjectSendStream,
14
+ ObjectStream,
15
+ TaskGroup,
16
+ )
17
+
18
+ T_Item = TypeVar("T_Item")
19
+ T_Stream = TypeVar("T_Stream")
20
+
21
+
22
+ @dataclass(eq=False)
23
+ class StapledByteStream(ByteStream):
24
+ """
25
+ Combines two byte streams into a single, bidirectional byte stream.
26
+
27
+ Extra attributes will be provided from both streams, with the receive stream
28
+ providing the values in case of a conflict.
29
+
30
+ :param ByteSendStream send_stream: the sending byte stream
31
+ :param ByteReceiveStream receive_stream: the receiving byte stream
32
+ """
33
+
34
+ send_stream: ByteSendStream
35
+ receive_stream: ByteReceiveStream
36
+
37
+ async def receive(self, max_bytes: int = 65536) -> bytes:
38
+ return await self.receive_stream.receive(max_bytes)
39
+
40
+ async def send(self, item: bytes) -> None:
41
+ await self.send_stream.send(item)
42
+
43
+ async def send_eof(self) -> None:
44
+ await self.send_stream.aclose()
45
+
46
+ async def aclose(self) -> None:
47
+ await self.send_stream.aclose()
48
+ await self.receive_stream.aclose()
49
+
50
+ @property
51
+ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
52
+ return {
53
+ **self.send_stream.extra_attributes,
54
+ **self.receive_stream.extra_attributes,
55
+ }
56
+
57
+
58
+ @dataclass(eq=False)
59
+ class StapledObjectStream(Generic[T_Item], ObjectStream[T_Item]):
60
+ """
61
+ Combines two object streams into a single, bidirectional object stream.
62
+
63
+ Extra attributes will be provided from both streams, with the receive stream
64
+ providing the values in case of a conflict.
65
+
66
+ :param ObjectSendStream send_stream: the sending object stream
67
+ :param ObjectReceiveStream receive_stream: the receiving object stream
68
+ """
69
+
70
+ send_stream: ObjectSendStream[T_Item]
71
+ receive_stream: ObjectReceiveStream[T_Item]
72
+
73
+ async def receive(self) -> T_Item:
74
+ return await self.receive_stream.receive()
75
+
76
+ async def send(self, item: T_Item) -> None:
77
+ await self.send_stream.send(item)
78
+
79
+ async def send_eof(self) -> None:
80
+ await self.send_stream.aclose()
81
+
82
+ async def aclose(self) -> None:
83
+ await self.send_stream.aclose()
84
+ await self.receive_stream.aclose()
85
+
86
+ @property
87
+ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
88
+ return {
89
+ **self.send_stream.extra_attributes,
90
+ **self.receive_stream.extra_attributes,
91
+ }
92
+
93
+
94
+ @dataclass(eq=False)
95
+ class MultiListener(Generic[T_Stream], Listener[T_Stream]):
96
+ """
97
+ Combines multiple listeners into one, serving connections from all of them at once.
98
+
99
+ Any MultiListeners in the given collection of listeners will have their listeners
100
+ moved into this one.
101
+
102
+ Extra attributes are provided from each listener, with each successive listener
103
+ overriding any conflicting attributes from the previous one.
104
+
105
+ :param listeners: listeners to serve
106
+ :type listeners: Sequence[Listener[T_Stream]]
107
+ """
108
+
109
+ listeners: Sequence[Listener[T_Stream]]
110
+
111
+ def __post_init__(self) -> None:
112
+ listeners: list[Listener[T_Stream]] = []
113
+ for listener in self.listeners:
114
+ if isinstance(listener, MultiListener):
115
+ listeners.extend(listener.listeners)
116
+ del listener.listeners[:] # type: ignore[attr-defined]
117
+ else:
118
+ listeners.append(listener)
119
+
120
+ self.listeners = listeners
121
+
122
+ async def serve(
123
+ self, handler: Callable[[T_Stream], Any], task_group: TaskGroup | None = None
124
+ ) -> None:
125
+ from .. import create_task_group
126
+
127
+ async with create_task_group() as tg:
128
+ for listener in self.listeners:
129
+ tg.start_soon(listener.serve, handler, task_group)
130
+
131
+ async def aclose(self) -> None:
132
+ for listener in self.listeners:
133
+ await listener.aclose()
134
+
135
+ @property
136
+ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
137
+ attributes: dict = {}
138
+ for listener in self.listeners:
139
+ attributes.update(listener.extra_attributes)
140
+
141
+ return attributes
miniconda3/lib/python3.13/site-packages/anyio/streams/text.py ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import codecs
4
+ import sys
5
+ from collections.abc import Callable, Mapping
6
+ from dataclasses import InitVar, dataclass, field
7
+ from typing import Any
8
+
9
+ from ..abc import (
10
+ AnyByteReceiveStream,
11
+ AnyByteSendStream,
12
+ AnyByteStream,
13
+ AnyByteStreamConnectable,
14
+ ObjectReceiveStream,
15
+ ObjectSendStream,
16
+ ObjectStream,
17
+ ObjectStreamConnectable,
18
+ )
19
+
20
+ if sys.version_info >= (3, 12):
21
+ from typing import override
22
+ else:
23
+ from typing_extensions import override
24
+
25
+
26
+ @dataclass(eq=False)
27
+ class TextReceiveStream(ObjectReceiveStream[str]):
28
+ """
29
+ Stream wrapper that decodes bytes to strings using the given encoding.
30
+
31
+ Decoding is done using :class:`~codecs.IncrementalDecoder` which returns any
32
+ completely received unicode characters as soon as they come in.
33
+
34
+ :param transport_stream: any bytes-based receive stream
35
+ :param encoding: character encoding to use for decoding bytes to strings (defaults
36
+ to ``utf-8``)
37
+ :param errors: handling scheme for decoding errors (defaults to ``strict``; see the
38
+ `codecs module documentation`_ for a comprehensive list of options)
39
+
40
+ .. _codecs module documentation:
41
+ https://docs.python.org/3/library/codecs.html#codec-objects
42
+ """
43
+
44
+ transport_stream: AnyByteReceiveStream
45
+ encoding: InitVar[str] = "utf-8"
46
+ errors: InitVar[str] = "strict"
47
+ _decoder: codecs.IncrementalDecoder = field(init=False)
48
+
49
+ def __post_init__(self, encoding: str, errors: str) -> None:
50
+ decoder_class = codecs.getincrementaldecoder(encoding)
51
+ self._decoder = decoder_class(errors=errors)
52
+
53
+ async def receive(self) -> str:
54
+ while True:
55
+ chunk = await self.transport_stream.receive()
56
+ decoded = self._decoder.decode(chunk)
57
+ if decoded:
58
+ return decoded
59
+
60
+ async def aclose(self) -> None:
61
+ await self.transport_stream.aclose()
62
+ self._decoder.reset()
63
+
64
+ @property
65
+ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
66
+ return self.transport_stream.extra_attributes
67
+
68
+
69
+ @dataclass(eq=False)
70
+ class TextSendStream(ObjectSendStream[str]):
71
+ """
72
+ Sends strings to the wrapped stream as bytes using the given encoding.
73
+
74
+ :param AnyByteSendStream transport_stream: any bytes-based send stream
75
+ :param str encoding: character encoding to use for encoding strings to bytes
76
+ (defaults to ``utf-8``)
77
+ :param str errors: handling scheme for encoding errors (defaults to ``strict``; see
78
+ the `codecs module documentation`_ for a comprehensive list of options)
79
+
80
+ .. _codecs module documentation:
81
+ https://docs.python.org/3/library/codecs.html#codec-objects
82
+ """
83
+
84
+ transport_stream: AnyByteSendStream
85
+ encoding: InitVar[str] = "utf-8"
86
+ errors: str = "strict"
87
+ _encoder: Callable[..., tuple[bytes, int]] = field(init=False)
88
+
89
+ def __post_init__(self, encoding: str) -> None:
90
+ self._encoder = codecs.getencoder(encoding)
91
+
92
+ async def send(self, item: str) -> None:
93
+ encoded = self._encoder(item, self.errors)[0]
94
+ await self.transport_stream.send(encoded)
95
+
96
+ async def aclose(self) -> None:
97
+ await self.transport_stream.aclose()
98
+
99
+ @property
100
+ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
101
+ return self.transport_stream.extra_attributes
102
+
103
+
104
+ @dataclass(eq=False)
105
+ class TextStream(ObjectStream[str]):
106
+ """
107
+ A bidirectional stream that decodes bytes to strings on receive and encodes strings
108
+ to bytes on send.
109
+
110
+ Extra attributes will be provided from both streams, with the receive stream
111
+ providing the values in case of a conflict.
112
+
113
+ :param AnyByteStream transport_stream: any bytes-based stream
114
+ :param str encoding: character encoding to use for encoding/decoding strings to/from
115
+ bytes (defaults to ``utf-8``)
116
+ :param str errors: handling scheme for encoding errors (defaults to ``strict``; see
117
+ the `codecs module documentation`_ for a comprehensive list of options)
118
+
119
+ .. _codecs module documentation:
120
+ https://docs.python.org/3/library/codecs.html#codec-objects
121
+ """
122
+
123
+ transport_stream: AnyByteStream
124
+ encoding: InitVar[str] = "utf-8"
125
+ errors: InitVar[str] = "strict"
126
+ _receive_stream: TextReceiveStream = field(init=False)
127
+ _send_stream: TextSendStream = field(init=False)
128
+
129
+ def __post_init__(self, encoding: str, errors: str) -> None:
130
+ self._receive_stream = TextReceiveStream(
131
+ self.transport_stream, encoding=encoding, errors=errors
132
+ )
133
+ self._send_stream = TextSendStream(
134
+ self.transport_stream, encoding=encoding, errors=errors
135
+ )
136
+
137
+ async def receive(self) -> str:
138
+ return await self._receive_stream.receive()
139
+
140
+ async def send(self, item: str) -> None:
141
+ await self._send_stream.send(item)
142
+
143
+ async def send_eof(self) -> None:
144
+ await self.transport_stream.send_eof()
145
+
146
+ async def aclose(self) -> None:
147
+ await self._send_stream.aclose()
148
+ await self._receive_stream.aclose()
149
+
150
+ @property
151
+ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
152
+ return {
153
+ **self._send_stream.extra_attributes,
154
+ **self._receive_stream.extra_attributes,
155
+ }
156
+
157
+
158
+ class TextConnectable(ObjectStreamConnectable[str]):
159
+ def __init__(self, connectable: AnyByteStreamConnectable):
160
+ """
161
+ :param connectable: the bytestream endpoint to wrap
162
+
163
+ """
164
+ self.connectable = connectable
165
+
166
+ @override
167
+ async def connect(self) -> TextStream:
168
+ stream = await self.connectable.connect()
169
+ return TextStream(stream)
miniconda3/lib/python3.13/site-packages/anyio/streams/tls.py ADDED
@@ -0,0 +1,417 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+ import re
5
+ import ssl
6
+ import sys
7
+ from collections.abc import Callable, Mapping
8
+ from dataclasses import dataclass
9
+ from functools import wraps
10
+ from ssl import SSLContext
11
+ from typing import Any, TypeVar
12
+
13
+ from .. import (
14
+ BrokenResourceError,
15
+ EndOfStream,
16
+ aclose_forcefully,
17
+ get_cancelled_exc_class,
18
+ to_thread,
19
+ )
20
+ from .._core._typedattr import TypedAttributeSet, typed_attribute
21
+ from ..abc import (
22
+ AnyByteStream,
23
+ AnyByteStreamConnectable,
24
+ ByteStream,
25
+ ByteStreamConnectable,
26
+ Listener,
27
+ TaskGroup,
28
+ )
29
+
30
+ if sys.version_info >= (3, 10):
31
+ from typing import TypeAlias
32
+ else:
33
+ from typing_extensions import TypeAlias
34
+
35
+ if sys.version_info >= (3, 11):
36
+ from typing import TypeVarTuple, Unpack
37
+ else:
38
+ from typing_extensions import TypeVarTuple, Unpack
39
+
40
+ if sys.version_info >= (3, 12):
41
+ from typing import override
42
+ else:
43
+ from typing_extensions import override
44
+
45
+ T_Retval = TypeVar("T_Retval")
46
+ PosArgsT = TypeVarTuple("PosArgsT")
47
+ _PCTRTT: TypeAlias = tuple[tuple[str, str], ...]
48
+ _PCTRTTT: TypeAlias = tuple[_PCTRTT, ...]
49
+
50
+
51
+ class TLSAttribute(TypedAttributeSet):
52
+ """Contains Transport Layer Security related attributes."""
53
+
54
+ #: the selected ALPN protocol
55
+ alpn_protocol: str | None = typed_attribute()
56
+ #: the channel binding for type ``tls-unique``
57
+ channel_binding_tls_unique: bytes = typed_attribute()
58
+ #: the selected cipher
59
+ cipher: tuple[str, str, int] = typed_attribute()
60
+ #: the peer certificate in dictionary form (see :meth:`ssl.SSLSocket.getpeercert`
61
+ # for more information)
62
+ peer_certificate: None | (dict[str, str | _PCTRTTT | _PCTRTT]) = typed_attribute()
63
+ #: the peer certificate in binary form
64
+ peer_certificate_binary: bytes | None = typed_attribute()
65
+ #: ``True`` if this is the server side of the connection
66
+ server_side: bool = typed_attribute()
67
+ #: ciphers shared by the client during the TLS handshake (``None`` if this is the
68
+ #: client side)
69
+ shared_ciphers: list[tuple[str, str, int]] | None = typed_attribute()
70
+ #: the :class:`~ssl.SSLObject` used for encryption
71
+ ssl_object: ssl.SSLObject = typed_attribute()
72
+ #: ``True`` if this stream does (and expects) a closing TLS handshake when the
73
+ #: stream is being closed
74
+ standard_compatible: bool = typed_attribute()
75
+ #: the TLS protocol version (e.g. ``TLSv1.2``)
76
+ tls_version: str = typed_attribute()
77
+
78
+
79
+ @dataclass(eq=False)
80
+ class TLSStream(ByteStream):
81
+ """
82
+ A stream wrapper that encrypts all sent data and decrypts received data.
83
+
84
+ This class has no public initializer; use :meth:`wrap` instead.
85
+ All extra attributes from :class:`~TLSAttribute` are supported.
86
+
87
+ :var AnyByteStream transport_stream: the wrapped stream
88
+
89
+ """
90
+
91
+ transport_stream: AnyByteStream
92
+ standard_compatible: bool
93
+ _ssl_object: ssl.SSLObject
94
+ _read_bio: ssl.MemoryBIO
95
+ _write_bio: ssl.MemoryBIO
96
+
97
+ @classmethod
98
+ async def wrap(
99
+ cls,
100
+ transport_stream: AnyByteStream,
101
+ *,
102
+ server_side: bool | None = None,
103
+ hostname: str | None = None,
104
+ ssl_context: ssl.SSLContext | None = None,
105
+ standard_compatible: bool = True,
106
+ ) -> TLSStream:
107
+ """
108
+ Wrap an existing stream with Transport Layer Security.
109
+
110
+ This performs a TLS handshake with the peer.
111
+
112
+ :param transport_stream: a bytes-transporting stream to wrap
113
+ :param server_side: ``True`` if this is the server side of the connection,
114
+ ``False`` if this is the client side (if omitted, will be set to ``False``
115
+ if ``hostname`` has been provided, ``False`` otherwise). Used only to create
116
+ a default context when an explicit context has not been provided.
117
+ :param hostname: host name of the peer (if host name checking is desired)
118
+ :param ssl_context: the SSLContext object to use (if not provided, a secure
119
+ default will be created)
120
+ :param standard_compatible: if ``False``, skip the closing handshake when
121
+ closing the connection, and don't raise an exception if the peer does the
122
+ same
123
+ :raises ~ssl.SSLError: if the TLS handshake fails
124
+
125
+ """
126
+ if server_side is None:
127
+ server_side = not hostname
128
+
129
+ if not ssl_context:
130
+ purpose = (
131
+ ssl.Purpose.CLIENT_AUTH if server_side else ssl.Purpose.SERVER_AUTH
132
+ )
133
+ ssl_context = ssl.create_default_context(purpose)
134
+
135
+ # Re-enable detection of unexpected EOFs if it was disabled by Python
136
+ if hasattr(ssl, "OP_IGNORE_UNEXPECTED_EOF"):
137
+ ssl_context.options &= ~ssl.OP_IGNORE_UNEXPECTED_EOF
138
+
139
+ bio_in = ssl.MemoryBIO()
140
+ bio_out = ssl.MemoryBIO()
141
+
142
+ # External SSLContext implementations may do blocking I/O in wrap_bio(),
143
+ # but the standard library implementation won't
144
+ if type(ssl_context) is ssl.SSLContext:
145
+ ssl_object = ssl_context.wrap_bio(
146
+ bio_in, bio_out, server_side=server_side, server_hostname=hostname
147
+ )
148
+ else:
149
+ ssl_object = await to_thread.run_sync(
150
+ ssl_context.wrap_bio,
151
+ bio_in,
152
+ bio_out,
153
+ server_side,
154
+ hostname,
155
+ None,
156
+ )
157
+
158
+ wrapper = cls(
159
+ transport_stream=transport_stream,
160
+ standard_compatible=standard_compatible,
161
+ _ssl_object=ssl_object,
162
+ _read_bio=bio_in,
163
+ _write_bio=bio_out,
164
+ )
165
+ await wrapper._call_sslobject_method(ssl_object.do_handshake)
166
+ return wrapper
167
+
168
+ async def _call_sslobject_method(
169
+ self, func: Callable[[Unpack[PosArgsT]], T_Retval], *args: Unpack[PosArgsT]
170
+ ) -> T_Retval:
171
+ while True:
172
+ try:
173
+ result = func(*args)
174
+ except ssl.SSLWantReadError:
175
+ try:
176
+ # Flush any pending writes first
177
+ if self._write_bio.pending:
178
+ await self.transport_stream.send(self._write_bio.read())
179
+
180
+ data = await self.transport_stream.receive()
181
+ except EndOfStream:
182
+ self._read_bio.write_eof()
183
+ except OSError as exc:
184
+ self._read_bio.write_eof()
185
+ self._write_bio.write_eof()
186
+ raise BrokenResourceError from exc
187
+ else:
188
+ self._read_bio.write(data)
189
+ except ssl.SSLWantWriteError:
190
+ await self.transport_stream.send(self._write_bio.read())
191
+ except ssl.SSLSyscallError as exc:
192
+ self._read_bio.write_eof()
193
+ self._write_bio.write_eof()
194
+ raise BrokenResourceError from exc
195
+ except ssl.SSLError as exc:
196
+ self._read_bio.write_eof()
197
+ self._write_bio.write_eof()
198
+ if isinstance(exc, ssl.SSLEOFError) or (
199
+ exc.strerror and "UNEXPECTED_EOF_WHILE_READING" in exc.strerror
200
+ ):
201
+ if self.standard_compatible:
202
+ raise BrokenResourceError from exc
203
+ else:
204
+ raise EndOfStream from None
205
+
206
+ raise
207
+ else:
208
+ # Flush any pending writes first
209
+ if self._write_bio.pending:
210
+ await self.transport_stream.send(self._write_bio.read())
211
+
212
+ return result
213
+
214
+ async def unwrap(self) -> tuple[AnyByteStream, bytes]:
215
+ """
216
+ Does the TLS closing handshake.
217
+
218
+ :return: a tuple of (wrapped byte stream, bytes left in the read buffer)
219
+
220
+ """
221
+ await self._call_sslobject_method(self._ssl_object.unwrap)
222
+ self._read_bio.write_eof()
223
+ self._write_bio.write_eof()
224
+ return self.transport_stream, self._read_bio.read()
225
+
226
+ async def aclose(self) -> None:
227
+ if self.standard_compatible:
228
+ try:
229
+ await self.unwrap()
230
+ except BaseException:
231
+ await aclose_forcefully(self.transport_stream)
232
+ raise
233
+
234
+ await self.transport_stream.aclose()
235
+
236
+ async def receive(self, max_bytes: int = 65536) -> bytes:
237
+ data = await self._call_sslobject_method(self._ssl_object.read, max_bytes)
238
+ if not data:
239
+ raise EndOfStream
240
+
241
+ return data
242
+
243
+ async def send(self, item: bytes) -> None:
244
+ await self._call_sslobject_method(self._ssl_object.write, item)
245
+
246
+ async def send_eof(self) -> None:
247
+ tls_version = self.extra(TLSAttribute.tls_version)
248
+ match = re.match(r"TLSv(\d+)(?:\.(\d+))?", tls_version)
249
+ if match:
250
+ major, minor = int(match.group(1)), int(match.group(2) or 0)
251
+ if (major, minor) < (1, 3):
252
+ raise NotImplementedError(
253
+ f"send_eof() requires at least TLSv1.3; current "
254
+ f"session uses {tls_version}"
255
+ )
256
+
257
+ raise NotImplementedError(
258
+ "send_eof() has not yet been implemented for TLS streams"
259
+ )
260
+
261
+ @property
262
+ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
263
+ return {
264
+ **self.transport_stream.extra_attributes,
265
+ TLSAttribute.alpn_protocol: self._ssl_object.selected_alpn_protocol,
266
+ TLSAttribute.channel_binding_tls_unique: (
267
+ self._ssl_object.get_channel_binding
268
+ ),
269
+ TLSAttribute.cipher: self._ssl_object.cipher,
270
+ TLSAttribute.peer_certificate: lambda: self._ssl_object.getpeercert(False),
271
+ TLSAttribute.peer_certificate_binary: lambda: self._ssl_object.getpeercert(
272
+ True
273
+ ),
274
+ TLSAttribute.server_side: lambda: self._ssl_object.server_side,
275
+ TLSAttribute.shared_ciphers: lambda: self._ssl_object.shared_ciphers()
276
+ if self._ssl_object.server_side
277
+ else None,
278
+ TLSAttribute.standard_compatible: lambda: self.standard_compatible,
279
+ TLSAttribute.ssl_object: lambda: self._ssl_object,
280
+ TLSAttribute.tls_version: self._ssl_object.version,
281
+ }
282
+
283
+
284
+ @dataclass(eq=False)
285
+ class TLSListener(Listener[TLSStream]):
286
+ """
287
+ A convenience listener that wraps another listener and auto-negotiates a TLS session
288
+ on every accepted connection.
289
+
290
+ If the TLS handshake times out or raises an exception,
291
+ :meth:`handle_handshake_error` is called to do whatever post-mortem processing is
292
+ deemed necessary.
293
+
294
+ Supports only the :attr:`~TLSAttribute.standard_compatible` extra attribute.
295
+
296
+ :param Listener listener: the listener to wrap
297
+ :param ssl_context: the SSL context object
298
+ :param standard_compatible: a flag passed through to :meth:`TLSStream.wrap`
299
+ :param handshake_timeout: time limit for the TLS handshake
300
+ (passed to :func:`~anyio.fail_after`)
301
+ """
302
+
303
+ listener: Listener[Any]
304
+ ssl_context: ssl.SSLContext
305
+ standard_compatible: bool = True
306
+ handshake_timeout: float = 30
307
+
308
+ @staticmethod
309
+ async def handle_handshake_error(exc: BaseException, stream: AnyByteStream) -> None:
310
+ """
311
+ Handle an exception raised during the TLS handshake.
312
+
313
+ This method does 3 things:
314
+
315
+ #. Forcefully closes the original stream
316
+ #. Logs the exception (unless it was a cancellation exception) using the
317
+ ``anyio.streams.tls`` logger
318
+ #. Reraises the exception if it was a base exception or a cancellation exception
319
+
320
+ :param exc: the exception
321
+ :param stream: the original stream
322
+
323
+ """
324
+ await aclose_forcefully(stream)
325
+
326
+ # Log all except cancellation exceptions
327
+ if not isinstance(exc, get_cancelled_exc_class()):
328
+ # CPython (as of 3.11.5) returns incorrect `sys.exc_info()` here when using
329
+ # any asyncio implementation, so we explicitly pass the exception to log
330
+ # (https://github.com/python/cpython/issues/108668). Trio does not have this
331
+ # issue because it works around the CPython bug.
332
+ logging.getLogger(__name__).exception(
333
+ "Error during TLS handshake", exc_info=exc
334
+ )
335
+
336
+ # Only reraise base exceptions and cancellation exceptions
337
+ if not isinstance(exc, Exception) or isinstance(exc, get_cancelled_exc_class()):
338
+ raise
339
+
340
+ async def serve(
341
+ self,
342
+ handler: Callable[[TLSStream], Any],
343
+ task_group: TaskGroup | None = None,
344
+ ) -> None:
345
+ @wraps(handler)
346
+ async def handler_wrapper(stream: AnyByteStream) -> None:
347
+ from .. import fail_after
348
+
349
+ try:
350
+ with fail_after(self.handshake_timeout):
351
+ wrapped_stream = await TLSStream.wrap(
352
+ stream,
353
+ ssl_context=self.ssl_context,
354
+ standard_compatible=self.standard_compatible,
355
+ )
356
+ except BaseException as exc:
357
+ await self.handle_handshake_error(exc, stream)
358
+ else:
359
+ await handler(wrapped_stream)
360
+
361
+ await self.listener.serve(handler_wrapper, task_group)
362
+
363
+ async def aclose(self) -> None:
364
+ await self.listener.aclose()
365
+
366
+ @property
367
+ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
368
+ return {
369
+ TLSAttribute.standard_compatible: lambda: self.standard_compatible,
370
+ }
371
+
372
+
373
+ class TLSConnectable(ByteStreamConnectable):
374
+ """
375
+ Wraps another connectable and does TLS negotiation after a successful connection.
376
+
377
+ :param connectable: the connectable to wrap
378
+ :param hostname: host name of the server (if host name checking is desired)
379
+ :param ssl_context: the SSLContext object to use (if not provided, a secure default
380
+ will be created)
381
+ :param standard_compatible: if ``False``, skip the closing handshake when closing
382
+ the connection, and don't raise an exception if the server does the same
383
+ """
384
+
385
+ def __init__(
386
+ self,
387
+ connectable: AnyByteStreamConnectable,
388
+ *,
389
+ hostname: str | None = None,
390
+ ssl_context: ssl.SSLContext | None = None,
391
+ standard_compatible: bool = True,
392
+ ) -> None:
393
+ self.connectable = connectable
394
+ self.ssl_context: SSLContext = ssl_context or ssl.create_default_context(
395
+ ssl.Purpose.SERVER_AUTH
396
+ )
397
+ if not isinstance(self.ssl_context, ssl.SSLContext):
398
+ raise TypeError(
399
+ "ssl_context must be an instance of ssl.SSLContext, not "
400
+ f"{type(self.ssl_context).__name__}"
401
+ )
402
+ self.hostname = hostname
403
+ self.standard_compatible = standard_compatible
404
+
405
+ @override
406
+ async def connect(self) -> TLSStream:
407
+ stream = await self.connectable.connect()
408
+ try:
409
+ return await TLSStream.wrap(
410
+ stream,
411
+ hostname=self.hostname,
412
+ ssl_context=self.ssl_context,
413
+ standard_compatible=self.standard_compatible,
414
+ )
415
+ except BaseException:
416
+ await aclose_forcefully(stream)
417
+ raise
miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ conda
miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/METADATA ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: archspec
3
+ Version: 0.2.5
4
+ Summary: A library to query system architecture
5
+ License: Apache-2.0 OR MIT
6
+ License-File: LICENSE-APACHE
7
+ License-File: LICENSE-MIT
8
+ License-File: NOTICE
9
+ Author: archspec developers
10
+ Author-email: maintainers@spack.io
11
+ Maintainer: Greg Becker
12
+ Maintainer-email: maintainers@spack.io
13
+ Requires-Python: >=3.6, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Information Technology
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: License :: Other/Proprietary License
19
+ Classifier: Operating System :: MacOS
20
+ Classifier: Operating System :: POSIX :: Linux
21
+ Classifier: Operating System :: Unix
22
+ Classifier: Programming Language :: Python :: 3
23
+ Classifier: Programming Language :: Python :: 3.7
24
+ Classifier: Programming Language :: Python :: 3.8
25
+ Classifier: Programming Language :: Python :: 3.9
26
+ Classifier: Programming Language :: Python :: 3.10
27
+ Classifier: Programming Language :: Python :: 3.11
28
+ Classifier: Programming Language :: Python :: 3.12
29
+ Classifier: Programming Language :: Python :: 3.13
30
+ Classifier: Programming Language :: Python :: 3.14
31
+ Project-URL: Documentation, https://archspec.readthedocs.io
32
+ Project-URL: Homepage, https://github.com/archspec/archspec
33
+ Project-URL: Repository, https://github.com/archspec/archspec.git
34
+ Description-Content-Type: text/markdown
35
+
36
+ # Archspec (Python bindings)
37
+
38
+ [![CI](https://github.com/archspec/archspec/workflows/Unit%20tests/badge.svg)](https://github.com/archspec/archspec/actions)
39
+ [![CodeCov](https://codecov.io/gh/archspec/archspec/branch/master/graph/badge.svg)](https://codecov.io/gh/archspec/archspec)
40
+ [![Documentation Status](https://readthedocs.org/projects/archspec/badge/?version=latest)](https://archspec.readthedocs.io/en/latest/?badge=latest)
41
+
42
+ Archspec aims at providing a standard set of human-understandable labels for
43
+ various aspects of a system architecture like CPU, network fabrics, etc. and
44
+ APIs to detect, query and compare them.
45
+
46
+ This project grew out of [Spack](https://spack.io/) and is currently under
47
+ active development. At present it supports APIs to detect and model
48
+ compatibility relationships among different CPU microarchitectures.
49
+
50
+ ## Getting started with development
51
+
52
+ The `archspec` Python package needs [poetry](https://python-poetry.org/) to
53
+ be installed from VCS sources. The preferred method to install it is via
54
+ its custom installer outside of any virtual environment:
55
+
56
+ ```console
57
+ curl -sSL https://install.python-poetry.org | python3 -
58
+ ```
59
+
60
+ You can refer to [Poetry's documentation](https://python-poetry.org/docs/#installation)
61
+ for further details or for other methods to install this tool. You'll also need `tox`
62
+ to run unit test:
63
+
64
+ ```console
65
+ pip install --user tox
66
+ ```
67
+
68
+ Finally, you'll need to clone the repository:
69
+
70
+ ```console
71
+ git clone --recursive https://github.com/archspec/archspec.git
72
+ ```
73
+
74
+ ### Running unit tests
75
+
76
+ Once you have your environment ready you can run `archspec` unit tests
77
+ using ``tox`` from the root of the repository:
78
+
79
+ ```console
80
+ $ tox
81
+ [ ... ]
82
+ py27: commands succeeded
83
+ py35: commands succeeded
84
+ py36: commands succeeded
85
+ py37: commands succeeded
86
+ py38: commands succeeded
87
+ pylint: commands succeeded
88
+ flake8: commands succeeded
89
+ black: commands succeeded
90
+ congratulations :)
91
+ ```
92
+
93
+ ## Citing Archspec
94
+
95
+ If you are referencing `archspec` in a publication, please cite the following
96
+ paper:
97
+
98
+ * Massimiliano Culpo, Gregory Becker, Carlos Eduardo Arango Gutierrez, Kenneth
99
+ Hoste, and Todd Gamblin.
100
+ [**`archspec`: A library for detecting, labeling, and reasoning about
101
+ microarchitectures**](https://tgamblin.github.io/pubs/archspec-canopie-hpc-2020.pdf).
102
+ In *2nd International Workshop on Containers and New Orchestration Paradigms
103
+ for Isolated Environments in HPC (CANOPIE-HPC'20)*, Online Event, November
104
+ 12, 2020.
105
+
106
+ ## License
107
+
108
+ Archspec is distributed under the terms of both the MIT license and the
109
+ Apache License (Version 2.0). Users may choose either license, at their
110
+ option.
111
+
112
+ All new contributions must be made under both the MIT and Apache-2.0
113
+ licenses.
114
+
115
+ See [LICENSE-MIT](https://github.com/archspec/archspec/blob/master/LICENSE-MIT),
116
+ [LICENSE-APACHE](https://github.com/archspec/archspec/blob/master/LICENSE-APACHE),
117
+ [COPYRIGHT](https://github.com/archspec/archspec/blob/master/COPYRIGHT), and
118
+ [NOTICE](https://github.com/archspec/archspec/blob/master/NOTICE) for details.
119
+
120
+ SPDX-License-Identifier: (Apache-2.0 OR MIT)
121
+
122
+ LLNL-CODE-811653
123
+
miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/RECORD ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ../../../bin/archspec,sha256=GF-Fy76-9whVsvLe1qu63xMH8EWOcvd65f29nRJUgZc,467
2
+ archspec-0.2.5.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
3
+ archspec-0.2.5.dist-info/METADATA,sha256=Rsa-lHKler8MX_jhHwyafwQu95u8tA0gqBBneIocKJ4,4565
4
+ archspec-0.2.5.dist-info/RECORD,,
5
+ archspec-0.2.5.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ archspec-0.2.5.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
7
+ archspec-0.2.5.dist-info/direct_url.json,sha256=tEankn611kBkC1j5rz91rAIMmzz4mcUiVeCbDiiHDmw,98
8
+ archspec-0.2.5.dist-info/entry_points.txt,sha256=v6umiu5eQSD6088Viyvkjlc1WVSHKK0LADMa7rMpNm4,46
9
+ archspec-0.2.5.dist-info/licenses/LICENSE-APACHE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
10
+ archspec-0.2.5.dist-info/licenses/LICENSE-MIT,sha256=kAGtmaZiB1oOWmqaU5_HUEDYBjw_clHWg5ykC1I0BU4,1171
11
+ archspec-0.2.5.dist-info/licenses/NOTICE,sha256=9CR93geVKl_4ZrJORbXN0fzkEM2y4DglWhY1hn9ZwQw,1167
12
+ archspec/__init__.py,sha256=l_vGH4wKXB5bmg7ZqNh-xA8EVUkpJpAS5l7V07ic0kE,67
13
+ archspec/__main__.py,sha256=lZu3C2P9FbOlE5GBeoSTqgdPycvcQcL7N8ihsdZGXYM,97
14
+ archspec/__pycache__/__init__.cpython-313.pyc,,
15
+ archspec/__pycache__/__main__.cpython-313.pyc,,
16
+ archspec/__pycache__/cli.cpython-313.pyc,,
17
+ archspec/cli.py,sha256=qgqXH-9b1bbssm00LOQmeiZkTuZJIgymXwAbtCDVk9Y,1691
18
+ archspec/cpu/__init__.py,sha256=OEkFUxPe0veRJL2bd4kYwzE8fJ8_V9UAtMB2bEyAVsM,727
19
+ archspec/cpu/__pycache__/__init__.cpython-313.pyc,,
20
+ archspec/cpu/__pycache__/alias.cpython-313.pyc,,
21
+ archspec/cpu/__pycache__/detect.cpython-313.pyc,,
22
+ archspec/cpu/__pycache__/microarchitecture.cpython-313.pyc,,
23
+ archspec/cpu/__pycache__/schema.cpython-313.pyc,,
24
+ archspec/cpu/alias.py,sha256=GrJPaWX6-FtoepF3z2G8RwikaB-_slHVT54yFQtOLU0,2506
25
+ archspec/cpu/detect.py,sha256=zId1RmKtEk3658M3SVD1_xED_9UsKRIWMTsOS5Ei5hw,16302
26
+ archspec/cpu/microarchitecture.py,sha256=I_XqoIumN4lnMb61x_PQEsIVEIndsvET4md5sI7jEJE,15210
27
+ archspec/cpu/schema.py,sha256=8CnUUDGzXaaGqbhSOQCTYT3wfoFLj4qFvFeedBtE5bM,3687
28
+ archspec/json/COPYRIGHT,sha256=nXDFqDfvpi337jffHHDd_8C7OOON8p3f3PoBRiQHzfs,805
29
+ archspec/json/LICENSE-APACHE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
30
+ archspec/json/LICENSE-MIT,sha256=kAGtmaZiB1oOWmqaU5_HUEDYBjw_clHWg5ykC1I0BU4,1171
31
+ archspec/json/NOTICE,sha256=9CR93geVKl_4ZrJORbXN0fzkEM2y4DglWhY1hn9ZwQw,1167
32
+ archspec/json/README.md,sha256=izG7TOmPb760cBmVawnPszxUtBlyyvHmKoxFrf3fK-g,1531
33
+ archspec/json/cpu/cpuid.json,sha256=gAWR57GoganHupdZX57v2CwXLVohSkx2hxkFL_r0-O0,20572
34
+ archspec/json/cpu/cpuid_schema.json,sha256=wIHbIUMywtjeBnZHGwL2g62sbagp6wrONj2x9y36pzg,3129
35
+ archspec/json/cpu/microarchitectures.json,sha256=upWYxLbsThV_YJQ5GPXXAL6d0VD6ytPW-WVqBIKU2YM,85601
36
+ archspec/json/cpu/microarchitectures_schema.json,sha256=EkHYbWfHs2k765QYU2gsoExocV_k9xt-_3LqAsGqhpU,3025
37
+ archspec/json/tests/targets/bgq-rhel6-power7,sha256=78gpbVDtmaehxm-I53_JD9_tYr8mkDJfUD9dA95akFg,116
38
+ archspec/json/tests/targets/darwin-bigsur-m1,sha256=ccXDP4oGNbOtTA16Zl9ntuh5R5JqnBlvZQT6m3U44Tw,534
39
+ archspec/json/tests/targets/darwin-mojave-haswell,sha256=x2dqKo4PYyQjA4O29lmGSuJuvbPwsT4LHYt60Pt0_sM,553
40
+ archspec/json/tests/targets/darwin-mojave-ivybridge,sha256=YEUVaxRSZmNa2Np5DpjAWdFwFG-o82njVKmwQDKVldw,2356
41
+ archspec/json/tests/targets/darwin-mojave-skylake,sha256=Hemmh6M0BvHs04nu2NELy20COML_94G1zH4bAumU_dg,598
42
+ archspec/json/tests/targets/darwin-monterey-m1,sha256=WSG9O446Q_SSD9vHuYj1SaI2zA6DhGtF3UU20xbnZ9s,3307
43
+ archspec/json/tests/targets/darwin-monterey-m2,sha256=ExCs3mYsAb3Lt6ZXDLI1pam9WrEfDNVhodphfVA7K6w,3307
44
+ archspec/json/tests/targets/linux-amazon-cortex_a72,sha256=P7YAipvudlo2U1PvUa01dDR2HKQURPeB2PHNu7kHRes,221
45
+ archspec/json/tests/targets/linux-amazon-neoverse_n1,sha256=zvHJOqLzHf4cTscllomBX2iSZNK45MiZ0z2jJ9AeDqk,276
46
+ archspec/json/tests/targets/linux-amazon-neoverse_v1,sha256=2RsWvKEIyHxVQunBRg_X71rdvq2dhPKRhKcsYdWb824,361
47
+ archspec/json/tests/targets/linux-amazon2-sapphirerapids,sha256=aRgatOvQJqJKnI62YC6FCuHxiMWtnwmba20_Ko0XI-k,1519
48
+ archspec/json/tests/targets/linux-asahi-m1,sha256=hKEOlbpmkV41_18D-XMig8TZV2FiZJLnBjYwZtpNrIQ,363
49
+ archspec/json/tests/targets/linux-asahi-m2,sha256=SKEtv3AhM-Zzzyr94GFirrF5UJKJTOOZqK33KulaBiI,381
50
+ archspec/json/tests/targets/linux-centos7-cascadelake,sha256=YYdo8G0bP85bn4dGdWePNDthEtAhhjKVRSXs3M7Yjg8,1408
51
+ archspec/json/tests/targets/linux-centos7-power8le,sha256=KgkGSkHLpk2vP4j0W3m7iHe559f-pxa2riWtAkIMRxo,111
52
+ archspec/json/tests/targets/linux-centos7-thunderx2,sha256=K8xsnq3W7EC-PXv5j3MsGrauowOARGOKj3_7-oOsNJI,238
53
+ archspec/json/tests/targets/linux-rhel6-piledriver,sha256=3YnQpTBgBi7FZtSCrJjAgx9DjFe92-sYoVJAprMBK_o,1411
54
+ archspec/json/tests/targets/linux-rhel7-broadwell,sha256=HBWEiyE2uKDYRS3C0rKspIb_5QypY5fs94NHEDSaPL0,1187
55
+ archspec/json/tests/targets/linux-rhel7-haswell,sha256=kq2qku54qPic_q-CnOw-RUj1nXTG6sZHBUDMhMyZz9g,1095
56
+ archspec/json/tests/targets/linux-rhel7-ivybridge,sha256=PC1NLw9ATBrCN7zHQszxbvHVvMHL1xUFpV1on94UM6Q,1009
57
+ archspec/json/tests/targets/linux-rhel7-skylake_avx512,sha256=3FI8aT-6OwBWE15FKoRDzTiz5BXqXYR5nFNTBg7Y9Qw,1286
58
+ archspec/json/tests/targets/linux-rhel7-x86_64_v3,sha256=D6iKhk9KQlb9qYetPdUBmDVNAVr-hGV297vDHLwe2FM,1172
59
+ archspec/json/tests/targets/linux-rhel7-zen,sha256=icybZCA-bXuasnJHS_qnU0tBpQgjy6-jDRitSC20J1E,1319
60
+ archspec/json/tests/targets/linux-rhel8-neoverse_v1,sha256=gtC-6MNgpPThX_HYYYHEivhqtirB32IlPscVI7kX3D0,351
61
+ archspec/json/tests/targets/linux-rhel8-power9,sha256=Ly0l0wku80CMdizv1UCKEx2Sip9S_0Bd0PTCfQPYHLc,135
62
+ archspec/json/tests/targets/linux-rhel9-neoverse_n2,sha256=tpQ9eG72iCemwazMMW_fGemCgTaSvn3JIUfJW74wyJw,429
63
+ archspec/json/tests/targets/linux-rhel9-neoverse_v2,sha256=XDV98FvAo7RdmI-RpS_ah8pdMWAcmO_sniJ5j1iVIHA,444
64
+ archspec/json/tests/targets/linux-rocky8-a64fx,sha256=rVo-uqYEJnlgPXAhbt-La1W25CR_xfb03rh0t520_1M,256
65
+ archspec/json/tests/targets/linux-rocky8.5-zen4,sha256=y4UDQdOxsg0Hl461XlBD_tPb_TX8EcXV7bwiHQn6zFM,1750
66
+ archspec/json/tests/targets/linux-rocky9-zen5,sha256=_HcNkfT5QjYOl2_55xJA-gd2DFvmhCHOZxK3q63rF5o,1882
67
+ archspec/json/tests/targets/linux-scientific7-k10,sha256=xEhQCc5CIqBWOoe28rvrW-BnjZSkOEBv0gXLQM5yAnE,1111
68
+ archspec/json/tests/targets/linux-scientific7-piledriver,sha256=kKCspg6gamWgMe9h9Mx5hP5O1DXgXOI6iH2B2BfwjDg,1149
69
+ archspec/json/tests/targets/linux-scientificfermi6-bulldozer,sha256=ZmboNqzZEsWWwOwBV_vmrNIi6x1E3E76Uz4Ej15Fu2s,1201
70
+ archspec/json/tests/targets/linux-scientificfermi6-piledriver,sha256=5pVZpVPXtKmqKK1Ps2LmYagCWhWTbjI5co_1QjYjZxI,1099
71
+ archspec/json/tests/targets/linux-sifive-u74mc,sha256=NGnvrcK3VP4qmWk7eZNIAgNED6yvyfcEBasMTmsHgck,124
72
+ archspec/json/tests/targets/linux-ubuntu18.04-broadwell,sha256=Azb3xc9WvgxBvQRNC5m83SJpqr73iLrGSJVJ5s4_zNI,1190
73
+ archspec/json/tests/targets/linux-ubuntu20.04-zen3,sha256=Y7Cws4kwzBlNupQhGl_2woA_1_SWxRqwgzn9NaT3_kg,1531
74
+ archspec/json/tests/targets/linux-ubuntu22.04-neoverse_n2,sha256=TR6C4HX2QRciUAwzaJSfTxL7K427NnC_SlfnUTqxFe4,396
75
+ archspec/json/tests/targets/linux-ubuntu22.04-neoverse_v2,sha256=FrkEGxnf-indDzUhuyxoMLiURAuC-2Wdk5-FYf0pOSg,458
76
+ archspec/json/tests/targets/linux-unknown-neoverse_v2,sha256=hQfDm2tcyRf3-kwhMTUow2aZujxqbVlnzUEjNaxQC3g,447
77
+ archspec/json/tests/targets/linux-unknown-power10,sha256=7ntCWmXGCTJkfZMMB0mIAk7fe2J7NlO11j0kjKkaSUM,83
78
+ archspec/json/tests/targets/linux-unknown-sapphirerapids,sha256=8AAkJoXaLkNhmcMqUp725T_MIWeyxkarU4poi_Zb0YE,2187
79
+ archspec/json/tests/targets/windows-cpuid-broadwell,sha256=ph0TRQor1s33j9IVjtbE6ZD4-wq7iilty2vnVb4UHDk,395
80
+ archspec/json/tests/targets/windows-cpuid-icelake,sha256=b2JlmnPiUF5JBl3jHCmkRPvon9vCE7_s5NjPph5EGrI,432
81
+ archspec/vendor/cpuid/.git,sha256=hrvgEKtXq8SEhWOQXV_vXrt0dSbrahQy_qNQ1j4aswo,52
82
+ archspec/vendor/cpuid/.gitignore,sha256=JRpFSUVfuHv5eFgg3iaMvtq0hO-MNrYKq1pVwlrXp9M,12
83
+ archspec/vendor/cpuid/LICENSE,sha256=DfgRNgMm2fRV3fECBVNI_aDAMYxc06vKr-Kq0rttsu4,1079
84
+ archspec/vendor/cpuid/README.md,sha256=UPKqGnVjslsiGR2GgXJv-twnYdnFnmCF3_t5CLXmY0Q,2400
85
+ archspec/vendor/cpuid/__pycache__/cpuid.cpython-313.pyc,,
86
+ archspec/vendor/cpuid/__pycache__/example.cpython-313.pyc,,
87
+ archspec/vendor/cpuid/cpuid.py,sha256=hywlKGTKtPXySyJy67d4OLpaQLfwfsPgUvSPdaxanRQ,6037
88
+ archspec/vendor/cpuid/example.py,sha256=g3EUANGuzhu61l6Z-5iLedPEe_vfObKxys-R5qnI6MY,1855
miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/REQUESTED ADDED
File without changes
miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/WHEEL ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.2.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/direct_url.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"dir_info": {}, "url": "file:///home/task_175812491784513/conda-bld/archspec_1758124989039/work"}
miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/entry_points.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [console_scripts]
2
+ archspec=archspec.cli:main
3
+
miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/licenses/LICENSE-APACHE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/licenses/LICENSE-MIT ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2019-2020 Lawrence Livermore National Security, LLC and other
2
+ Archspec Project Developers. See the top-level COPYRIGHT file for details.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a
5
+ copy of this software and associated documentation files (the "Software"),
6
+ to deal in the Software without restriction, including without limitation
7
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
+ and/or sell copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20
+ DEALINGS IN THE SOFTWARE.
miniconda3/lib/python3.13/site-packages/archspec-0.2.5.dist-info/licenses/NOTICE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This work was produced under the auspices of the U.S. Department of
2
+ Energy by Lawrence Livermore National Laboratory under Contract
3
+ DE-AC52-07NA27344.
4
+
5
+ This work was prepared as an account of work sponsored by an agency of
6
+ the United States Government. Neither the United States Government nor
7
+ Lawrence Livermore National Security, LLC, nor any of their employees
8
+ makes any warranty, expressed or implied, or assumes any legal liability
9
+ or responsibility for the accuracy, completeness, or usefulness of any
10
+ information, apparatus, product, or process disclosed, or represents that
11
+ its use would not infringe privately owned rights.
12
+
13
+ Reference herein to any specific commercial product, process, or service
14
+ by trade name, trademark, manufacturer, or otherwise does not necessarily
15
+ constitute or imply its endorsement, recommendation, or favoring by the
16
+ United States Government or Lawrence Livermore National Security, LLC.
17
+
18
+ The views and opinions of authors expressed herein do not necessarily
19
+ state or reflect those of the United States Government or Lawrence
20
+ Livermore National Security, LLC, and shall not be used for advertising
21
+ or product endorsement purposes.
miniconda3/lib/python3.13/site-packages/archspec/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ """Init file to avoid namespace packages"""
2
+
3
+ __version__ = "0.2.5"
miniconda3/lib/python3.13/site-packages/archspec/__main__.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Run the `archspec` CLI as a module.
3
+ """
4
+
5
+ import sys
6
+
7
+ from .cli import main
8
+
9
+ sys.exit(main())