@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
File without changes
@@ -0,0 +1,247 @@
1
+ #!/usr/bin/env python3
2
+ """This is a file that wraps calls to `pyright --verifytypes`, achieving two things:
3
+ 1. give an error if docstrings are missing.
4
+ pyright will give a number of missing docstrings, and error messages, but not exit with a non-zero value.
5
+ 2. filter out specific errors we don't care about.
6
+ this is largely due to 1, but also because Trio does some very complex stuff and --verifytypes has few to no ways of ignoring specific errors.
7
+
8
+ If this check is giving you false alarms, you can ignore them by adding logic to `has_docstring_at_runtime`, in the main loop in `check_type`, or by updating the json file.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ # this file is not run as part of the tests, instead it's run standalone from check.sh
14
+ import argparse
15
+ import json
16
+ import subprocess
17
+ import sys
18
+ from pathlib import Path
19
+
20
+ import trio
21
+ import trio.testing
22
+
23
+ # not needed if everything is working, but if somebody does something to generate
24
+ # tons of errors, we can be nice and stop them from getting 3*tons of output
25
+ printed_diagnostics: set[str] = set()
26
+
27
+
28
+ # TODO: consider checking manually without `--ignoreexternal`, and/or
29
+ # removing it from the below call later on.
30
+ def run_pyright(platform: str) -> subprocess.CompletedProcess[bytes]:
31
+ return subprocess.run(
32
+ [
33
+ "pyright",
34
+ # Specify a platform and version to keep imported modules consistent.
35
+ f"--pythonplatform={platform}",
36
+ "--pythonversion=3.10",
37
+ "--verifytypes=trio",
38
+ "--outputjson",
39
+ "--ignoreexternal",
40
+ ],
41
+ capture_output=True,
42
+ )
43
+
44
+
45
+ def has_docstring_at_runtime(name: str) -> bool:
46
+ """Pyright gives us an object identifier of xx.yy.zz
47
+ This function tries to decompose that into its constituent parts, such that we
48
+ can resolve it, in order to check whether it has a `__doc__` at runtime and
49
+ verifytypes misses it because we're doing overly fancy stuff.
50
+ """
51
+ # This assert is solely for stopping isort from removing our imports of trio & trio.testing
52
+ # It could also be done with isort:skip, but that'd also disable import sorting and the like.
53
+ assert trio.testing is not None
54
+
55
+ # figure out what part of the name is the module, so we can "import" it
56
+ name_parts = name.split(".")
57
+ assert name_parts[0] == "trio"
58
+ if name_parts[1] == "tests":
59
+ return True
60
+
61
+ # traverse down the remaining identifiers with getattr
62
+ obj = trio
63
+ try:
64
+ for obj_name in name_parts[1:]:
65
+ obj = getattr(obj, obj_name)
66
+ except AttributeError as exc:
67
+ # asynciowrapper does funky getattr stuff
68
+ if "AsyncIOWrapper" in str(exc) or name in (
69
+ # Symbols not existing on all platforms, so we can't dynamically inspect them.
70
+ # Manually confirmed to have docstrings but pyright doesn't see them due to
71
+ # export shenanigans. TODO: actually manually confirm that.
72
+ # In theory we could verify these at runtime, probably by running the script separately
73
+ # on separate platforms. It might also be a decent idea to work the other way around,
74
+ # a la test_static_tool_sees_class_members
75
+ # darwin
76
+ "trio.lowlevel.current_kqueue",
77
+ "trio.lowlevel.monitor_kevent",
78
+ "trio.lowlevel.wait_kevent",
79
+ "trio._core._io_kqueue._KqueueStatistics",
80
+ # windows
81
+ "trio._socket.SocketType.share",
82
+ "trio._core._io_windows._WindowsStatistics",
83
+ "trio._core._windows_cffi.Handle",
84
+ "trio.lowlevel.current_iocp",
85
+ "trio.lowlevel.monitor_completion_key",
86
+ "trio.lowlevel.readinto_overlapped",
87
+ "trio.lowlevel.register_with_iocp",
88
+ "trio.lowlevel.wait_overlapped",
89
+ "trio.lowlevel.write_overlapped",
90
+ "trio.lowlevel.WaitForSingleObject",
91
+ "trio.socket.fromshare",
92
+ # linux
93
+ # this test will fail on linux, but I don't develop on linux. So the next
94
+ # person to do so is very welcome to open a pull request and populate with
95
+ # objects
96
+ # TODO: these are erroring on all platforms, why?
97
+ "trio._highlevel_generic.StapledStream.send_stream",
98
+ "trio._highlevel_generic.StapledStream.receive_stream",
99
+ "trio._ssl.SSLStream.transport_stream",
100
+ "trio._file_io._HasFileNo",
101
+ "trio._file_io._HasFileNo.fileno",
102
+ ):
103
+ return True
104
+
105
+ else:
106
+ print(
107
+ f"Pyright sees {name} at runtime, but unable to getattr({obj.__name__}, {obj_name}).",
108
+ file=sys.stderr,
109
+ )
110
+ return False
111
+ return bool(obj.__doc__)
112
+
113
+
114
+ def check_type(
115
+ platform: str,
116
+ full_diagnostics_file: Path | None,
117
+ expected_errors: list[object],
118
+ ) -> list[object]:
119
+ # convince isort we use the trio import
120
+ assert trio is not None
121
+
122
+ # run pyright, load output into json
123
+ res = run_pyright(platform)
124
+ current_result = json.loads(res.stdout)
125
+
126
+ if res.stderr:
127
+ print(res.stderr, file=sys.stderr)
128
+
129
+ if full_diagnostics_file:
130
+ with open(full_diagnostics_file, "a") as f:
131
+ json.dump(current_result, f, sort_keys=True, indent=4)
132
+
133
+ errors = []
134
+
135
+ for symbol in current_result["typeCompleteness"]["symbols"]:
136
+ diagnostics = symbol["diagnostics"]
137
+ name = symbol["name"]
138
+ for diagnostic in diagnostics:
139
+ message = diagnostic["message"]
140
+ if name in (
141
+ "trio._path.PosixPath",
142
+ "trio._path.WindowsPath",
143
+ ) and message.startswith("Type of base class "):
144
+ continue
145
+
146
+ if name.startswith("trio._path.Path"):
147
+ if message.startswith("No docstring found for"):
148
+ continue
149
+ if message.startswith(
150
+ "Type is missing type annotation and could be inferred differently by type checkers",
151
+ ):
152
+ continue
153
+
154
+ # ignore errors about missing docstrings if they're available at runtime
155
+ if message.startswith("No docstring found for"):
156
+ if has_docstring_at_runtime(symbol["name"]):
157
+ continue
158
+ else:
159
+ # Missing docstring messages include the name of the object.
160
+ # Other errors don't, so we add it.
161
+ message = f"{name}: {message}"
162
+ if message not in expected_errors and message not in printed_diagnostics:
163
+ print(f"new error: {message}", file=sys.stderr)
164
+ errors.append(message)
165
+ printed_diagnostics.add(message)
166
+
167
+ continue
168
+
169
+ return errors
170
+
171
+
172
+ def main(args: argparse.Namespace) -> int:
173
+ if args.full_diagnostics_file:
174
+ full_diagnostics_file = Path(args.full_diagnostics_file)
175
+ full_diagnostics_file.write_text("")
176
+ else:
177
+ full_diagnostics_file = None
178
+
179
+ errors_by_platform_file = Path(__file__).parent / "_check_type_completeness.json"
180
+ if errors_by_platform_file.exists():
181
+ with open(errors_by_platform_file) as f:
182
+ errors_by_platform = json.load(f)
183
+ else:
184
+ errors_by_platform = {"Linux": [], "Windows": [], "Darwin": [], "all": []}
185
+
186
+ changed = False
187
+ for platform in "Linux", "Windows", "Darwin":
188
+ platform_errors = errors_by_platform[platform] + errors_by_platform["all"]
189
+ print("*" * 20, f"\nChecking {platform}...")
190
+ errors = check_type(platform, full_diagnostics_file, platform_errors)
191
+
192
+ new_errors = [e for e in errors if e not in platform_errors]
193
+ missing_errors = [e for e in platform_errors if e not in errors]
194
+
195
+ if new_errors:
196
+ print(
197
+ f"New errors introduced in `pyright --verifytypes`. Fix them, or ignore them by modifying {errors_by_platform_file}, either manually or with '--overwrite-file'.",
198
+ file=sys.stderr,
199
+ )
200
+ changed = True
201
+ if missing_errors:
202
+ print(
203
+ f"Congratulations, you have resolved existing errors! Please remove them from {errors_by_platform_file}, either manually or with '--overwrite-file'.",
204
+ file=sys.stderr,
205
+ )
206
+ changed = True
207
+ print(missing_errors, file=sys.stderr)
208
+
209
+ errors_by_platform[platform] = errors
210
+ print("*" * 20)
211
+
212
+ # cut down the size of the json file by a lot, and make it easier to parse for
213
+ # humans, by moving errors that appear on all platforms to a separate category
214
+ errors_by_platform["all"] = []
215
+ for e in errors_by_platform["Linux"].copy():
216
+ if e in errors_by_platform["Darwin"] and e in errors_by_platform["Windows"]:
217
+ for platform in "Linux", "Windows", "Darwin":
218
+ errors_by_platform[platform].remove(e)
219
+ errors_by_platform["all"].append(e)
220
+
221
+ if changed and args.overwrite_file:
222
+ with open(errors_by_platform_file, "w") as f:
223
+ json.dump(errors_by_platform, f, indent=4, sort_keys=True)
224
+ # newline at end of file
225
+ f.write("\n")
226
+
227
+ # True -> 1 -> non-zero exit value -> error
228
+ return changed
229
+
230
+
231
+ parser = argparse.ArgumentParser()
232
+ parser.add_argument(
233
+ "--overwrite-file",
234
+ action="store_true",
235
+ default=False,
236
+ help="Use this flag to overwrite the current stored results. Either in CI together with a diff check, or to avoid having to manually correct it.",
237
+ )
238
+ parser.add_argument(
239
+ "--full-diagnostics-file",
240
+ type=Path,
241
+ default=None,
242
+ help="Use this for debugging, it will dump the output of all three pyright runs by platform into this file.",
243
+ )
244
+ args = parser.parse_args()
245
+
246
+ assert __name__ == "__main__", "This script should be run standalone"
247
+ sys.exit(main(args))
@@ -0,0 +1,22 @@
1
+ regular = "hi"
2
+
3
+ import sys
4
+
5
+ from .. import _deprecate
6
+
7
+ _deprecate.deprecate_attributes(
8
+ __name__,
9
+ {
10
+ "dep1": _deprecate.DeprecatedAttribute("value1", "1.1", issue=1),
11
+ "dep2": _deprecate.DeprecatedAttribute(
12
+ "value2",
13
+ "1.2",
14
+ issue=1,
15
+ instead="instead-string",
16
+ ),
17
+ },
18
+ )
19
+
20
+ this_mod = sys.modules[__name__]
21
+ assert this_mod.regular == "hi"
22
+ assert "dep1" not in globals()
@@ -0,0 +1,54 @@
1
+ from __future__ import annotations
2
+
3
+ import inspect
4
+ from typing import NoReturn
5
+
6
+ import pytest
7
+
8
+ from ..testing import MockClock, trio_test
9
+
10
+ RUN_SLOW = True
11
+ SKIP_OPTIONAL_IMPORTS = False
12
+
13
+
14
+ def pytest_addoption(parser: pytest.Parser) -> None:
15
+ parser.addoption("--run-slow", action="store_true", help="run slow tests")
16
+ parser.addoption(
17
+ "--skip-optional-imports",
18
+ action="store_true",
19
+ help="skip tests that rely on libraries not required by trio itself",
20
+ )
21
+
22
+
23
+ def pytest_configure(config: pytest.Config) -> None:
24
+ global RUN_SLOW
25
+ RUN_SLOW = config.getoption("--run-slow", default=True)
26
+ global SKIP_OPTIONAL_IMPORTS
27
+ SKIP_OPTIONAL_IMPORTS = config.getoption("--skip-optional-imports", default=False)
28
+
29
+
30
+ @pytest.fixture
31
+ def mock_clock() -> MockClock:
32
+ return MockClock()
33
+
34
+
35
+ @pytest.fixture
36
+ def autojump_clock() -> MockClock:
37
+ return MockClock(autojump_threshold=0)
38
+
39
+
40
+ # FIXME: split off into a package (or just make part of Trio's public
41
+ # interface?), with config file to enable? and I guess a mark option too; I
42
+ # guess it's useful with the class- and file-level marking machinery (where
43
+ # the raw @trio_test decorator isn't enough).
44
+ @pytest.hookimpl(tryfirst=True)
45
+ def pytest_pyfunc_call(pyfuncitem: pytest.Function) -> None:
46
+ if inspect.iscoroutinefunction(pyfuncitem.obj):
47
+ pyfuncitem.obj = trio_test(pyfuncitem.obj)
48
+
49
+
50
+ def skip_if_optional_else_raise(error: ImportError) -> NoReturn:
51
+ if SKIP_OPTIONAL_IMPORTS:
52
+ pytest.skip(error.msg, allow_module_level=True)
53
+ else: # pragma: no cover
54
+ raise error
@@ -0,0 +1,72 @@
1
+ from __future__ import annotations
2
+
3
+ import attrs
4
+ import pytest
5
+
6
+ from .. import abc as tabc
7
+ from ..lowlevel import Task
8
+
9
+
10
+ def test_instrument_implements_hook_methods() -> None:
11
+ attrs = {
12
+ "before_run": (),
13
+ "after_run": (),
14
+ "task_spawned": (Task,),
15
+ "task_scheduled": (Task,),
16
+ "before_task_step": (Task,),
17
+ "after_task_step": (Task,),
18
+ "task_exited": (Task,),
19
+ "before_io_wait": (3.3,),
20
+ "after_io_wait": (3.3,),
21
+ }
22
+
23
+ mayonnaise = tabc.Instrument()
24
+
25
+ for method_name, args in attrs.items():
26
+ assert hasattr(mayonnaise, method_name)
27
+ method = getattr(mayonnaise, method_name)
28
+ assert callable(method)
29
+ method(*args)
30
+
31
+
32
+ async def test_AsyncResource_defaults() -> None:
33
+ @attrs.define(slots=False)
34
+ class MyAR(tabc.AsyncResource):
35
+ record: list[str] = attrs.Factory(list)
36
+
37
+ async def aclose(self) -> None:
38
+ self.record.append("ac")
39
+
40
+ async with MyAR() as myar:
41
+ assert isinstance(myar, MyAR)
42
+ assert myar.record == []
43
+
44
+ assert myar.record == ["ac"]
45
+
46
+
47
+ def test_abc_generics() -> None:
48
+ # Pythons below 3.5.2 had a typing.Generic that would throw
49
+ # errors when instantiating or subclassing a parameterized
50
+ # version of a class with any __slots__. This is why RunVar
51
+ # (which has slots) is not generic. This tests that
52
+ # the generic ABCs are fine, because while they are slotted
53
+ # they don't actually define any slots.
54
+
55
+ class SlottedChannel(tabc.SendChannel[tabc.Stream]):
56
+ __slots__ = ("x",)
57
+
58
+ def send_nowait(self, value: object) -> None:
59
+ raise RuntimeError
60
+
61
+ async def send(self, value: object) -> None:
62
+ raise RuntimeError # pragma: no cover
63
+
64
+ def clone(self) -> None:
65
+ raise RuntimeError # pragma: no cover
66
+
67
+ async def aclose(self) -> None:
68
+ pass # pragma: no cover
69
+
70
+ channel = SlottedChannel()
71
+ with pytest.raises(RuntimeError):
72
+ channel.send_nowait(None)