@ajksunkang-aios/kgraph-linux-x64 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/bin/kgraph-launcher +15 -3
  2. package/lib/kgraph/scripts/build-bundle.sh +17 -4
  3. package/lib/site-packages/outcome/__init__.py +20 -0
  4. package/lib/site-packages/outcome/_impl.py +239 -0
  5. package/lib/site-packages/outcome/_util.py +33 -0
  6. package/lib/site-packages/outcome/_version.py +7 -0
  7. package/lib/site-packages/outcome/py.typed +0 -0
  8. package/lib/site-packages/outcome-1.3.0.post0.dist-info/INSTALLER +1 -0
  9. package/lib/site-packages/outcome-1.3.0.post0.dist-info/LICENSE +3 -0
  10. package/lib/site-packages/outcome-1.3.0.post0.dist-info/LICENSE.APACHE2 +202 -0
  11. package/lib/site-packages/outcome-1.3.0.post0.dist-info/LICENSE.MIT +20 -0
  12. package/lib/site-packages/outcome-1.3.0.post0.dist-info/METADATA +63 -0
  13. package/lib/site-packages/outcome-1.3.0.post0.dist-info/RECORD +13 -0
  14. package/lib/site-packages/outcome-1.3.0.post0.dist-info/WHEEL +6 -0
  15. package/lib/site-packages/outcome-1.3.0.post0.dist-info/top_level.txt +1 -0
  16. package/lib/site-packages/sniffio/__init__.py +17 -0
  17. package/lib/site-packages/sniffio/_impl.py +95 -0
  18. package/lib/site-packages/sniffio/_tests/__init__.py +0 -0
  19. package/lib/site-packages/sniffio/_tests/test_sniffio.py +84 -0
  20. package/lib/site-packages/sniffio/_version.py +3 -0
  21. package/lib/site-packages/sniffio/py.typed +0 -0
  22. package/lib/site-packages/sniffio-1.3.1.dist-info/INSTALLER +1 -0
  23. package/lib/site-packages/sniffio-1.3.1.dist-info/LICENSE +3 -0
  24. package/lib/site-packages/sniffio-1.3.1.dist-info/LICENSE.APACHE2 +202 -0
  25. package/lib/site-packages/sniffio-1.3.1.dist-info/LICENSE.MIT +20 -0
  26. package/lib/site-packages/sniffio-1.3.1.dist-info/METADATA +104 -0
  27. package/lib/site-packages/sniffio-1.3.1.dist-info/RECORD +14 -0
  28. package/lib/site-packages/sniffio-1.3.1.dist-info/WHEEL +5 -0
  29. package/lib/site-packages/sniffio-1.3.1.dist-info/top_level.txt +1 -0
  30. package/lib/site-packages/sortedcontainers/__init__.py +74 -0
  31. package/lib/site-packages/sortedcontainers/sorteddict.py +812 -0
  32. package/lib/site-packages/sortedcontainers/sortedlist.py +2646 -0
  33. package/lib/site-packages/sortedcontainers/sortedset.py +733 -0
  34. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/INSTALLER +1 -0
  35. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/LICENSE +13 -0
  36. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/METADATA +264 -0
  37. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/RECORD +10 -0
  38. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/WHEEL +6 -0
  39. package/lib/site-packages/sortedcontainers-2.4.0.dist-info/top_level.txt +1 -0
  40. package/lib/site-packages/trio/__init__.py +133 -0
  41. package/lib/site-packages/trio/__main__.py +3 -0
  42. package/lib/site-packages/trio/_abc.py +714 -0
  43. package/lib/site-packages/trio/_channel.py +610 -0
  44. package/lib/site-packages/trio/_core/__init__.py +94 -0
  45. package/lib/site-packages/trio/_core/_asyncgens.py +243 -0
  46. package/lib/site-packages/trio/_core/_concat_tb.py +26 -0
  47. package/lib/site-packages/trio/_core/_entry_queue.py +223 -0
  48. package/lib/site-packages/trio/_core/_exceptions.py +169 -0
  49. package/lib/site-packages/trio/_core/_generated_instrumentation.py +50 -0
  50. package/lib/site-packages/trio/_core/_generated_io_epoll.py +98 -0
  51. package/lib/site-packages/trio/_core/_generated_io_kqueue.py +153 -0
  52. package/lib/site-packages/trio/_core/_generated_io_windows.py +204 -0
  53. package/lib/site-packages/trio/_core/_generated_run.py +269 -0
  54. package/lib/site-packages/trio/_core/_generated_windows_ffi.py +10 -0
  55. package/lib/site-packages/trio/_core/_instrumentation.py +117 -0
  56. package/lib/site-packages/trio/_core/_io_common.py +31 -0
  57. package/lib/site-packages/trio/_core/_io_epoll.py +385 -0
  58. package/lib/site-packages/trio/_core/_io_kqueue.py +292 -0
  59. package/lib/site-packages/trio/_core/_io_windows.py +1036 -0
  60. package/lib/site-packages/trio/_core/_ki.py +271 -0
  61. package/lib/site-packages/trio/_core/_local.py +104 -0
  62. package/lib/site-packages/trio/_core/_mock_clock.py +165 -0
  63. package/lib/site-packages/trio/_core/_parking_lot.py +317 -0
  64. package/lib/site-packages/trio/_core/_run.py +3148 -0
  65. package/lib/site-packages/trio/_core/_run_context.py +15 -0
  66. package/lib/site-packages/trio/_core/_tests/__init__.py +0 -0
  67. package/lib/site-packages/trio/_core/_tests/test_asyncgen.py +339 -0
  68. package/lib/site-packages/trio/_core/_tests/test_cancelled.py +222 -0
  69. package/lib/site-packages/trio/_core/_tests/test_exceptiongroup_gc.py +103 -0
  70. package/lib/site-packages/trio/_core/_tests/test_guest_mode.py +755 -0
  71. package/lib/site-packages/trio/_core/_tests/test_instrumentation.py +315 -0
  72. package/lib/site-packages/trio/_core/_tests/test_io.py +522 -0
  73. package/lib/site-packages/trio/_core/_tests/test_ki.py +703 -0
  74. package/lib/site-packages/trio/_core/_tests/test_local.py +118 -0
  75. package/lib/site-packages/trio/_core/_tests/test_mock_clock.py +193 -0
  76. package/lib/site-packages/trio/_core/_tests/test_parking_lot.py +389 -0
  77. package/lib/site-packages/trio/_core/_tests/test_run.py +3024 -0
  78. package/lib/site-packages/trio/_core/_tests/test_thread_cache.py +227 -0
  79. package/lib/site-packages/trio/_core/_tests/test_tutil.py +13 -0
  80. package/lib/site-packages/trio/_core/_tests/test_unbounded_queue.py +154 -0
  81. package/lib/site-packages/trio/_core/_tests/test_windows.py +305 -0
  82. package/lib/site-packages/trio/_core/_tests/tutil.py +117 -0
  83. package/lib/site-packages/trio/_core/_tests/type_tests/nursery_start.py +79 -0
  84. package/lib/site-packages/trio/_core/_tests/type_tests/run.py +51 -0
  85. package/lib/site-packages/trio/_core/_thread_cache.py +317 -0
  86. package/lib/site-packages/trio/_core/_traps.py +318 -0
  87. package/lib/site-packages/trio/_core/_unbounded_queue.py +163 -0
  88. package/lib/site-packages/trio/_core/_wakeup_socketpair.py +75 -0
  89. package/lib/site-packages/trio/_core/_windows_cffi.py +313 -0
  90. package/lib/site-packages/trio/_deprecate.py +171 -0
  91. package/lib/site-packages/trio/_dtls.py +1380 -0
  92. package/lib/site-packages/trio/_file_io.py +513 -0
  93. package/lib/site-packages/trio/_highlevel_generic.py +125 -0
  94. package/lib/site-packages/trio/_highlevel_open_tcp_listeners.py +251 -0
  95. package/lib/site-packages/trio/_highlevel_open_tcp_stream.py +397 -0
  96. package/lib/site-packages/trio/_highlevel_open_unix_stream.py +65 -0
  97. package/lib/site-packages/trio/_highlevel_serve_listeners.py +148 -0
  98. package/lib/site-packages/trio/_highlevel_socket.py +423 -0
  99. package/lib/site-packages/trio/_highlevel_ssl_helpers.py +180 -0
  100. package/lib/site-packages/trio/_path.py +289 -0
  101. package/lib/site-packages/trio/_repl.py +159 -0
  102. package/lib/site-packages/trio/_signals.py +185 -0
  103. package/lib/site-packages/trio/_socket.py +1326 -0
  104. package/lib/site-packages/trio/_ssl.py +964 -0
  105. package/lib/site-packages/trio/_subprocess.py +1178 -0
  106. package/lib/site-packages/trio/_subprocess_platform/__init__.py +123 -0
  107. package/lib/site-packages/trio/_subprocess_platform/kqueue.py +48 -0
  108. package/lib/site-packages/trio/_subprocess_platform/waitid.py +113 -0
  109. package/lib/site-packages/trio/_subprocess_platform/windows.py +11 -0
  110. package/lib/site-packages/trio/_sync.py +908 -0
  111. package/lib/site-packages/trio/_tests/__init__.py +0 -0
  112. package/lib/site-packages/trio/_tests/astrill-codesigning-cert.cer +0 -0
  113. package/lib/site-packages/trio/_tests/check_type_completeness.py +247 -0
  114. package/lib/site-packages/trio/_tests/module_with_deprecations.py +22 -0
  115. package/lib/site-packages/trio/_tests/pytest_plugin.py +54 -0
  116. package/lib/site-packages/trio/_tests/test_abc.py +72 -0
  117. package/lib/site-packages/trio/_tests/test_channel.py +750 -0
  118. package/lib/site-packages/trio/_tests/test_contextvars.py +56 -0
  119. package/lib/site-packages/trio/_tests/test_deprecate.py +277 -0
  120. package/lib/site-packages/trio/_tests/test_deprecate_strict_exception_groups_false.py +64 -0
  121. package/lib/site-packages/trio/_tests/test_dtls.py +950 -0
  122. package/lib/site-packages/trio/_tests/test_exports.py +626 -0
  123. package/lib/site-packages/trio/_tests/test_fakenet.py +317 -0
  124. package/lib/site-packages/trio/_tests/test_file_io.py +269 -0
  125. package/lib/site-packages/trio/_tests/test_highlevel_generic.py +98 -0
  126. package/lib/site-packages/trio/_tests/test_highlevel_open_tcp_listeners.py +419 -0
  127. package/lib/site-packages/trio/_tests/test_highlevel_open_tcp_stream.py +693 -0
  128. package/lib/site-packages/trio/_tests/test_highlevel_open_unix_stream.py +86 -0
  129. package/lib/site-packages/trio/_tests/test_highlevel_serve_listeners.py +186 -0
  130. package/lib/site-packages/trio/_tests/test_highlevel_socket.py +336 -0
  131. package/lib/site-packages/trio/_tests/test_highlevel_ssl_helpers.py +169 -0
  132. package/lib/site-packages/trio/_tests/test_path.py +279 -0
  133. package/lib/site-packages/trio/_tests/test_repl.py +428 -0
  134. package/lib/site-packages/trio/_tests/test_scheduler_determinism.py +47 -0
  135. package/lib/site-packages/trio/_tests/test_signals.py +186 -0
  136. package/lib/site-packages/trio/_tests/test_socket.py +1253 -0
  137. package/lib/site-packages/trio/_tests/test_ssl.py +1371 -0
  138. package/lib/site-packages/trio/_tests/test_subprocess.py +767 -0
  139. package/lib/site-packages/trio/_tests/test_sync.py +735 -0
  140. package/lib/site-packages/trio/_tests/test_testing.py +682 -0
  141. package/lib/site-packages/trio/_tests/test_testing_raisesgroup.py +1128 -0
  142. package/lib/site-packages/trio/_tests/test_threads.py +1173 -0
  143. package/lib/site-packages/trio/_tests/test_timeouts.py +281 -0
  144. package/lib/site-packages/trio/_tests/test_tracing.py +88 -0
  145. package/lib/site-packages/trio/_tests/test_trio.py +8 -0
  146. package/lib/site-packages/trio/_tests/test_unix_pipes.py +288 -0
  147. package/lib/site-packages/trio/_tests/test_util.py +349 -0
  148. package/lib/site-packages/trio/_tests/test_wait_for_object.py +225 -0
  149. package/lib/site-packages/trio/_tests/test_windows_pipes.py +112 -0
  150. package/lib/site-packages/trio/_tests/tools/__init__.py +0 -0
  151. package/lib/site-packages/trio/_tests/tools/test_gen_exports.py +179 -0
  152. package/lib/site-packages/trio/_tests/tools/test_mypy_annotate.py +140 -0
  153. package/lib/site-packages/trio/_tests/tools/test_sync_requirements.py +80 -0
  154. package/lib/site-packages/trio/_tests/type_tests/check_wraps.py +9 -0
  155. package/lib/site-packages/trio/_tests/type_tests/open_memory_channel.py +4 -0
  156. package/lib/site-packages/trio/_tests/type_tests/path.py +140 -0
  157. package/lib/site-packages/trio/_tests/type_tests/subprocesses.py +23 -0
  158. package/lib/site-packages/trio/_tests/type_tests/task_status.py +29 -0
  159. package/lib/site-packages/trio/_threads.py +610 -0
  160. package/lib/site-packages/trio/_timeouts.py +197 -0
  161. package/lib/site-packages/trio/_tools/__init__.py +0 -0
  162. package/lib/site-packages/trio/_tools/gen_exports.py +401 -0
  163. package/lib/site-packages/trio/_tools/mypy_annotate.py +126 -0
  164. package/lib/site-packages/trio/_tools/sync_requirements.py +98 -0
  165. package/lib/site-packages/trio/_tools/windows_ffi_build.py +220 -0
  166. package/lib/site-packages/trio/_unix_pipes.py +197 -0
  167. package/lib/site-packages/trio/_util.py +385 -0
  168. package/lib/site-packages/trio/_version.py +3 -0
  169. package/lib/site-packages/trio/_wait_for_object.py +67 -0
  170. package/lib/site-packages/trio/_windows_pipes.py +144 -0
  171. package/lib/site-packages/trio/abc.py +23 -0
  172. package/lib/site-packages/trio/from_thread.py +13 -0
  173. package/lib/site-packages/trio/lowlevel.py +95 -0
  174. package/lib/site-packages/trio/py.typed +0 -0
  175. package/lib/site-packages/trio/socket.py +602 -0
  176. package/lib/site-packages/trio/testing/__init__.py +58 -0
  177. package/lib/site-packages/trio/testing/_check_streams.py +570 -0
  178. package/lib/site-packages/trio/testing/_checkpoints.py +69 -0
  179. package/lib/site-packages/trio/testing/_fake_net.py +584 -0
  180. package/lib/site-packages/trio/testing/_memory_streams.py +633 -0
  181. package/lib/site-packages/trio/testing/_network.py +36 -0
  182. package/lib/site-packages/trio/testing/_raises_group.py +1015 -0
  183. package/lib/site-packages/trio/testing/_sequencer.py +87 -0
  184. package/lib/site-packages/trio/testing/_trio_test.py +50 -0
  185. package/lib/site-packages/trio/to_thread.py +4 -0
  186. package/lib/site-packages/trio-0.33.0.dist-info/INSTALLER +1 -0
  187. package/lib/site-packages/trio-0.33.0.dist-info/METADATA +186 -0
  188. package/lib/site-packages/trio-0.33.0.dist-info/RECORD +156 -0
  189. package/lib/site-packages/trio-0.33.0.dist-info/REQUESTED +0 -0
  190. package/lib/site-packages/trio-0.33.0.dist-info/WHEEL +5 -0
  191. package/lib/site-packages/trio-0.33.0.dist-info/entry_points.txt +2 -0
  192. package/lib/site-packages/trio-0.33.0.dist-info/licenses/LICENSE +3 -0
  193. package/lib/site-packages/trio-0.33.0.dist-info/licenses/LICENSE.APACHE2 +202 -0
  194. package/lib/site-packages/trio-0.33.0.dist-info/licenses/LICENSE.MIT +22 -0
  195. package/lib/site-packages/trio-0.33.0.dist-info/top_level.txt +1 -0
  196. package/package.json +1 -1
@@ -0,0 +1,56 @@
1
+ from __future__ import annotations
2
+
3
+ import contextvars
4
+
5
+ from .. import _core
6
+
7
+ trio_testing_contextvar: contextvars.ContextVar[str] = contextvars.ContextVar(
8
+ "trio_testing_contextvar",
9
+ )
10
+
11
+
12
+ async def test_contextvars_default() -> None:
13
+ trio_testing_contextvar.set("main")
14
+ record: list[str] = []
15
+
16
+ async def child() -> None:
17
+ value = trio_testing_contextvar.get()
18
+ record.append(value)
19
+
20
+ async with _core.open_nursery() as nursery:
21
+ nursery.start_soon(child)
22
+ assert record == ["main"]
23
+
24
+
25
+ async def test_contextvars_set() -> None:
26
+ trio_testing_contextvar.set("main")
27
+ record: list[str] = []
28
+
29
+ async def child() -> None:
30
+ trio_testing_contextvar.set("child")
31
+ value = trio_testing_contextvar.get()
32
+ record.append(value)
33
+
34
+ async with _core.open_nursery() as nursery:
35
+ nursery.start_soon(child)
36
+ value = trio_testing_contextvar.get()
37
+ assert record == ["child"]
38
+ assert value == "main"
39
+
40
+
41
+ async def test_contextvars_copy() -> None:
42
+ trio_testing_contextvar.set("main")
43
+ context = contextvars.copy_context()
44
+ trio_testing_contextvar.set("second_main")
45
+ record: list[str] = []
46
+
47
+ async def child() -> None:
48
+ value = trio_testing_contextvar.get()
49
+ record.append(value)
50
+
51
+ async with _core.open_nursery() as nursery:
52
+ context.run(nursery.start_soon, child)
53
+ nursery.start_soon(child)
54
+ value = trio_testing_contextvar.get()
55
+ assert set(record) == {"main", "second_main"}
56
+ assert value == "second_main"
@@ -0,0 +1,277 @@
1
+ from __future__ import annotations
2
+
3
+ import inspect
4
+ import warnings
5
+ from types import ModuleType
6
+
7
+ import pytest
8
+
9
+ from .._deprecate import (
10
+ TrioDeprecationWarning,
11
+ deprecated,
12
+ deprecated_alias,
13
+ warn_deprecated,
14
+ )
15
+ from . import module_with_deprecations
16
+
17
+
18
+ @pytest.fixture
19
+ def recwarn_always(recwarn: pytest.WarningsRecorder) -> pytest.WarningsRecorder:
20
+ warnings.simplefilter("always")
21
+ # ResourceWarnings about unclosed sockets can occur nondeterministically
22
+ # (during GC) which throws off the tests in this file
23
+ warnings.simplefilter("ignore", ResourceWarning)
24
+ return recwarn
25
+
26
+
27
+ def _here() -> tuple[str, int]:
28
+ frame = inspect.currentframe()
29
+ assert frame is not None
30
+ assert frame.f_back is not None
31
+ info = inspect.getframeinfo(frame.f_back)
32
+ return (info.filename, info.lineno)
33
+
34
+
35
+ def test_warn_deprecated(recwarn_always: pytest.WarningsRecorder) -> None:
36
+ def deprecated_thing() -> None:
37
+ warn_deprecated("ice", "1.2", issue=1, instead="water")
38
+
39
+ deprecated_thing()
40
+ filename, lineno = _here()
41
+ assert len(recwarn_always) == 1
42
+ got = recwarn_always.pop(DeprecationWarning)
43
+ assert isinstance(got.message, Warning)
44
+ assert "ice is deprecated" in got.message.args[0]
45
+ assert "Trio 1.2" in got.message.args[0]
46
+ assert "water instead" in got.message.args[0]
47
+ assert "/issues/1" in got.message.args[0]
48
+ assert got.filename == filename
49
+ assert got.lineno == lineno - 1
50
+
51
+
52
+ def test_warn_deprecated_no_instead_or_issue(
53
+ recwarn_always: pytest.WarningsRecorder,
54
+ ) -> None:
55
+ # Explicitly no instead or issue
56
+ warn_deprecated("water", "1.3", issue=None, instead=None)
57
+ assert len(recwarn_always) == 1
58
+ got = recwarn_always.pop(DeprecationWarning)
59
+ assert isinstance(got.message, Warning)
60
+ assert "water is deprecated" in got.message.args[0]
61
+ assert "no replacement" in got.message.args[0]
62
+ assert "Trio 1.3" in got.message.args[0]
63
+
64
+
65
+ def test_warn_deprecated_stacklevel(recwarn_always: pytest.WarningsRecorder) -> None:
66
+ def nested1() -> None:
67
+ nested2()
68
+
69
+ def nested2() -> None:
70
+ warn_deprecated("x", "1.3", issue=7, instead="y", stacklevel=3)
71
+
72
+ filename, lineno = _here()
73
+ nested1()
74
+ got = recwarn_always.pop(DeprecationWarning)
75
+ assert got.filename == filename
76
+ assert got.lineno == lineno + 1
77
+
78
+
79
+ def old() -> None: # pragma: no cover
80
+ pass
81
+
82
+
83
+ def new() -> None: # pragma: no cover
84
+ pass
85
+
86
+
87
+ def test_warn_deprecated_formatting(recwarn_always: pytest.WarningsRecorder) -> None:
88
+ warn_deprecated(old, "1.0", issue=1, instead=new)
89
+ got = recwarn_always.pop(DeprecationWarning)
90
+ assert isinstance(got.message, Warning)
91
+ assert "test_deprecate.old is deprecated" in got.message.args[0]
92
+ assert "test_deprecate.new instead" in got.message.args[0]
93
+
94
+
95
+ @deprecated("1.5", issue=123, instead=new)
96
+ def deprecated_old() -> int:
97
+ return 3
98
+
99
+
100
+ def test_deprecated_decorator(recwarn_always: pytest.WarningsRecorder) -> None:
101
+ assert deprecated_old() == 3
102
+ got = recwarn_always.pop(DeprecationWarning)
103
+ assert isinstance(got.message, Warning)
104
+ assert "test_deprecate.deprecated_old is deprecated" in got.message.args[0]
105
+ assert "1.5" in got.message.args[0]
106
+ assert "test_deprecate.new" in got.message.args[0]
107
+ assert "issues/123" in got.message.args[0]
108
+
109
+
110
+ class Foo:
111
+ @deprecated("1.0", issue=123, instead="crying")
112
+ def method(self) -> int:
113
+ return 7
114
+
115
+
116
+ def test_deprecated_decorator_method(recwarn_always: pytest.WarningsRecorder) -> None:
117
+ f = Foo()
118
+ assert f.method() == 7
119
+ got = recwarn_always.pop(DeprecationWarning)
120
+ assert isinstance(got.message, Warning)
121
+ assert "test_deprecate.Foo.method is deprecated" in got.message.args[0]
122
+
123
+
124
+ @deprecated("1.2", thing="the thing", issue=None, instead=None)
125
+ def deprecated_with_thing() -> int:
126
+ return 72
127
+
128
+
129
+ def test_deprecated_decorator_with_explicit_thing(
130
+ recwarn_always: pytest.WarningsRecorder,
131
+ ) -> None:
132
+ assert deprecated_with_thing() == 72
133
+ got = recwarn_always.pop(DeprecationWarning)
134
+ assert isinstance(got.message, Warning)
135
+ assert "the thing is deprecated" in got.message.args[0]
136
+
137
+
138
+ def new_hotness() -> str:
139
+ return "new hotness"
140
+
141
+
142
+ old_hotness = deprecated_alias("old_hotness", new_hotness, "1.23", issue=1)
143
+
144
+
145
+ def test_deprecated_alias(recwarn_always: pytest.WarningsRecorder) -> None:
146
+ assert old_hotness() == "new hotness"
147
+ got = recwarn_always.pop(DeprecationWarning)
148
+ assert isinstance(got.message, Warning)
149
+ assert "test_deprecate.old_hotness is deprecated" in got.message.args[0]
150
+ assert "1.23" in got.message.args[0]
151
+ assert "test_deprecate.new_hotness instead" in got.message.args[0]
152
+ assert "issues/1" in got.message.args[0]
153
+
154
+ assert isinstance(old_hotness.__doc__, str)
155
+ assert ".. deprecated:: 1.23" in old_hotness.__doc__
156
+ assert "test_deprecate.new_hotness instead" in old_hotness.__doc__
157
+ assert "issues/1>`__" in old_hotness.__doc__
158
+
159
+
160
+ class Alias:
161
+ def new_hotness_method(self) -> str:
162
+ return "new hotness method"
163
+
164
+ old_hotness_method = deprecated_alias(
165
+ "Alias.old_hotness_method",
166
+ new_hotness_method,
167
+ "3.21",
168
+ issue=1,
169
+ )
170
+
171
+
172
+ def test_deprecated_alias_method(recwarn_always: pytest.WarningsRecorder) -> None:
173
+ obj = Alias()
174
+ assert obj.old_hotness_method() == "new hotness method"
175
+ got = recwarn_always.pop(DeprecationWarning)
176
+ assert isinstance(got.message, Warning)
177
+ msg = got.message.args[0]
178
+ assert "test_deprecate.Alias.old_hotness_method is deprecated" in msg
179
+ assert "test_deprecate.Alias.new_hotness_method instead" in msg
180
+
181
+
182
+ @deprecated("2.1", issue=1, instead="hi")
183
+ def docstring_test1() -> None: # pragma: no cover
184
+ """Hello!"""
185
+
186
+
187
+ @deprecated("2.1", issue=None, instead="hi")
188
+ def docstring_test2() -> None: # pragma: no cover
189
+ """Hello!"""
190
+
191
+
192
+ @deprecated("2.1", issue=1, instead=None)
193
+ def docstring_test3() -> None: # pragma: no cover
194
+ """Hello!"""
195
+
196
+
197
+ @deprecated("2.1", issue=None, instead=None)
198
+ def docstring_test4() -> None: # pragma: no cover
199
+ """Hello!"""
200
+
201
+
202
+ def test_deprecated_docstring_munging() -> None:
203
+ assert docstring_test1.__doc__ == """Hello!
204
+
205
+ .. deprecated:: 2.1
206
+ Use hi instead.
207
+ For details, see `issue #1 <https://github.com/python-trio/trio/issues/1>`__.
208
+
209
+ """
210
+
211
+ assert docstring_test2.__doc__ == """Hello!
212
+
213
+ .. deprecated:: 2.1
214
+ Use hi instead.
215
+
216
+ """
217
+
218
+ assert docstring_test3.__doc__ == """Hello!
219
+
220
+ .. deprecated:: 2.1
221
+ For details, see `issue #1 <https://github.com/python-trio/trio/issues/1>`__.
222
+
223
+ """
224
+
225
+ assert docstring_test4.__doc__ == """Hello!
226
+
227
+ .. deprecated:: 2.1
228
+
229
+ """
230
+
231
+
232
+ def test_module_with_deprecations(recwarn_always: pytest.WarningsRecorder) -> None:
233
+ assert module_with_deprecations.regular == "hi"
234
+ assert len(recwarn_always) == 0
235
+
236
+ assert type(module_with_deprecations) is ModuleType
237
+
238
+ filename, lineno = _here()
239
+ assert module_with_deprecations.dep1 == "value1" # type: ignore[attr-defined]
240
+ got = recwarn_always.pop(DeprecationWarning)
241
+ assert isinstance(got.message, Warning)
242
+ assert got.filename == filename
243
+ assert got.lineno == lineno + 1
244
+
245
+ assert "module_with_deprecations.dep1" in got.message.args[0]
246
+ assert "Trio 1.1" in got.message.args[0]
247
+ assert "/issues/1" in got.message.args[0]
248
+ assert "value1 instead" in got.message.args[0]
249
+
250
+ assert module_with_deprecations.dep2 == "value2" # type: ignore[attr-defined]
251
+ got = recwarn_always.pop(DeprecationWarning)
252
+ assert isinstance(got.message, Warning)
253
+ assert "instead-string instead" in got.message.args[0]
254
+
255
+ with pytest.raises(AttributeError):
256
+ module_with_deprecations.asdf # type: ignore[attr-defined] # noqa: B018 # "useless expression"
257
+
258
+
259
+ def test_warning_class() -> None:
260
+ with pytest.deprecated_call():
261
+ warn_deprecated("foo", "bar", issue=None, instead=None)
262
+
263
+ # essentially the same as the above check
264
+ with pytest.warns(
265
+ DeprecationWarning,
266
+ match="^foo is deprecated since Trio bar with no replacement$",
267
+ ):
268
+ warn_deprecated("foo", "bar", issue=None, instead=None)
269
+
270
+ with pytest.warns(TrioDeprecationWarning):
271
+ warn_deprecated(
272
+ "foo",
273
+ "bar",
274
+ issue=None,
275
+ instead=None,
276
+ use_triodeprecationwarning=True,
277
+ )
@@ -0,0 +1,64 @@
1
+ from collections.abc import Awaitable, Callable
2
+
3
+ import pytest
4
+
5
+ import trio
6
+
7
+
8
+ async def test_deprecation_warning_open_nursery() -> None:
9
+ with pytest.warns(
10
+ trio.TrioDeprecationWarning,
11
+ match="strict_exception_groups=False",
12
+ ) as record:
13
+ async with trio.open_nursery(strict_exception_groups=False):
14
+ ...
15
+ assert len(record) == 1
16
+ async with trio.open_nursery(strict_exception_groups=True):
17
+ ...
18
+ async with trio.open_nursery():
19
+ ...
20
+
21
+
22
+ def test_deprecation_warning_run() -> None:
23
+ async def foo() -> None: ...
24
+
25
+ async def foo_nursery() -> None:
26
+ # this should not raise a warning, even if it's implied loose
27
+ async with trio.open_nursery():
28
+ ...
29
+
30
+ async def foo_loose_nursery() -> None:
31
+ # this should raise a warning, even if specifying the parameter is redundant
32
+ async with trio.open_nursery(strict_exception_groups=False):
33
+ ...
34
+
35
+ def helper(fun: Callable[[], Awaitable[None]], num: int) -> None:
36
+ with pytest.warns(
37
+ trio.TrioDeprecationWarning,
38
+ match="strict_exception_groups=False",
39
+ ) as record:
40
+ trio.run(fun, strict_exception_groups=False)
41
+ assert len(record) == num
42
+
43
+ helper(foo, 1)
44
+ helper(foo_nursery, 1)
45
+ helper(foo_loose_nursery, 2)
46
+
47
+
48
+ def test_deprecation_warning_start_guest_run() -> None:
49
+ # "The simplest possible "host" loop."
50
+ from .._core._tests.test_guest_mode import trivial_guest_run
51
+
52
+ async def trio_return(in_host: object) -> str:
53
+ await trio.lowlevel.checkpoint()
54
+ return "ok"
55
+
56
+ with pytest.warns(
57
+ trio.TrioDeprecationWarning,
58
+ match="strict_exception_groups=False",
59
+ ) as record:
60
+ trivial_guest_run(
61
+ trio_return,
62
+ strict_exception_groups=False,
63
+ )
64
+ assert len(record) == 1