grpcreflect-py 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,219 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity granting the License.
13
+
14
+ "Legal Entity" shall mean the union of the acting entity and all
15
+ other entities that control, are controlled by, or are under common
16
+ control with that entity. For the purposes of this definition,
17
+ "control" means (i) the power, direct or indirect, to cause the
18
+ direction or management of such entity, whether by contract or
19
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity
23
+ exercising permissions granted by this License.
24
+
25
+ "Source" shall mean the preferred form for making modifications,
26
+ including but not limited to software source code, documentation
27
+ source, and configuration files.
28
+
29
+ "Object" shall mean any form resulting from mechanical
30
+ transformation or translation of a Source form, including but
31
+ not limited to compiled object code, generated documentation,
32
+ and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or
35
+ Object form, made available under the License, as indicated by a
36
+ copyright notice that is included in or attached to the work
37
+ (which shall not include communications that are solely limited to
38
+ and are identified as being limited to a portion of the work).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based upon (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and derivative works thereof.
47
+
48
+ "Contributor" shall mean Licensor and any individual or Legal Entity
49
+ on behalf of whom a Contribution has been made to Licensor. For the
50
+ purposes of this definition, "Contribution" shall mean any work of
51
+ authorship, including the original version of the Work and any
52
+ modifications or additions to that Work or Derivative Works thereof,
53
+ that is intentionally submitted to Licensor for inclusion in the Work
54
+ by the copyright owner or by an individual or Legal Entity authorized
55
+ to submit on behalf of the copyright owner. For the purposes of this
56
+ definition, "submitted" means any form of electronic, verbal, or
57
+ written communication sent to the Licensor or its representatives,
58
+ including but not limited to communication on electronic mailing
59
+ lists, source code control systems, and issue tracking systems that
60
+ are managed by, or on behalf of, the Licensor for the purpose of
61
+ discussing and improving the Work, but excluding communication that
62
+ is conspicuously marked or otherwise designated in writing by the
63
+ copyright owner as "Not a Contribution."
64
+
65
+ "Contributor" shall mean Licensor and any individual or Legal Entity
66
+ on behalf of whom a Contribution has been made to Licensor. For the
67
+ purposes of this definition, "Contribution" shall mean any work of
68
+ authorship, including the original version of the Work and any
69
+ modifications or additions to that Work or Derivative Works thereof,
70
+ that is intentionally submitted to Licensor for inclusion in the Work
71
+ by the copyright owner or by an individual or Legal Entity authorized
72
+ to submit on behalf of the copyright owner. For the purposes of this
73
+ definition, "submitted" means any form of electronic, verbal, or
74
+ written communication sent to the Licensor or its representatives,
75
+ including but not limited to communication on electronic mailing
76
+ lists, source code control systems, and issue tracking systems that
77
+ are managed by, or on behalf of, the Licensor for the purpose of
78
+ discussing and improving the Work, but excluding communication that
79
+ is conspicuously marked or otherwise designated in writing by the
80
+ copyright owner as "Not a Contribution."
81
+
82
+ 2. Grant of Copyright License. Subject to the terms and conditions of
83
+ this License, each Contributor hereby grants to You a perpetual,
84
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
85
+ copyright license to use, reproduce, modify, distribute, and prepare
86
+ Derivative Works of, publicly display, publicly perform, sublicense,
87
+ and distribute the Work and such Derivative Works in source or object
88
+ form.
89
+
90
+ 3. Grant of Patent License. Subject to the terms and conditions of
91
+ this License, each Contributor hereby grants to You a perpetual,
92
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
93
+ (except as stated in this section) patent license to make, have made,
94
+ use, offer to sell, sell, import, and otherwise transfer the Work,
95
+ where such license applies only to those patent claims licensable
96
+ by such Contributor that are necessarily infringed by their
97
+ Contribution(s) alone or by combination of their Contribution(s)
98
+ with the Work to which such Contribution(s) was submitted. If You
99
+ institute patent litigation against any entity (including a
100
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
101
+ or a Contribution incorporated within the Work constitutes direct
102
+ or contributory patent infringement, then any patent licenses
103
+ granted to You under this License for that Work shall terminate
104
+ as of the date such litigation is filed.
105
+
106
+ 4. Redistribution. You may reproduce and distribute copies of the
107
+ Work or Derivative Works thereof in any medium, with or without
108
+ modifications, and in source or object form, provided that You
109
+ meet the following conditions:
110
+
111
+ (a) You must give any other recipients of the Work or
112
+ Derivative Works a copy of this License; and
113
+
114
+ (b) You must cause any modified files to carry prominent notices
115
+ stating that You changed the files; and
116
+
117
+ (c) You must retain, in the Source form of any Derivative Works
118
+ that You distribute, all copyright, trademark, patent,
119
+ attribution and other notices from the Source form of the Work,
120
+ excluding those notices that do not pertain to any part of
121
+ the Derivative Works; and
122
+
123
+ (d) If the Work includes a "NOTICE" text file as part of its
124
+ distribution, then any Derivative Works that You distribute must
125
+ include a readable copy of the attribution notices contained
126
+ within such NOTICE file, excluding those notices that do not
127
+ pertain to any part of the Derivative Works, in at least one
128
+ of the following places: within a NOTICE text file distributed
129
+ as part of the Derivative Works; within the Source form or
130
+ documentation, if provided along with the Derivative Works; or,
131
+ within a display generated by the Derivative Works, if and
132
+ wherever such third-party notices normally appear. The contents
133
+ of the NOTICE file are for informational purposes only and
134
+ do not modify the License. You may add Your own attribution
135
+ notices within Derivative Works that You distribute, alongside
136
+ or as an addendum to the NOTICE text from the Work, provided
137
+ that such additional attribution notices cannot be construed
138
+ as modifying the License.
139
+
140
+ You may add Your own copyright notice to Your modifications and
141
+ may provide additional or different license terms and conditions
142
+ for use, reproduction, or distribution of Your modifications, or
143
+ for any such Derivative Works as a whole, provided Your use,
144
+ reproduction, and distribution of the Work otherwise complies with
145
+ the conditions stated in this License.
146
+
147
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
148
+ any Contribution intentionally submitted for inclusion in the Work
149
+ by You to the Licensor shall be under the terms and conditions of
150
+ this License, without any additional terms or conditions.
151
+ Notwithstanding the above, nothing herein shall supersede or modify
152
+ the terms of any separate license agreement you may have executed
153
+ with Licensor regarding such Contributions.
154
+
155
+ 6. Trademarks. This License does not grant permission to use the trade
156
+ names, trademarks, service marks, or product names of the Licensor,
157
+ except as required for reasonable and customary use in describing the
158
+ origin of the Work and reproducing the content of the NOTICE file.
159
+
160
+ 7. Disclaimer of Warranty. Unless required by applicable law or
161
+ agreed to in writing, Licensor provides the Work (and each
162
+ Contributor provides its Contributions) on an "AS IS" BASIS,
163
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
164
+ implied, including, without limitation, any warranties or conditions
165
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
166
+ PARTICULAR PURPOSE. You are solely responsible for determining the
167
+ appropriateness of using or redistributing the Work and assume any
168
+ risks associated with Your exercise of permissions under this License.
169
+
170
+ 8. Limitation of Liability. In no event and under no legal theory,
171
+ whether in tort (including negligence), contract, or otherwise,
172
+ unless required by applicable law (such as deliberate and grossly
173
+ negligent acts) or agreed to in writing, shall any Contributor be
174
+ liable to You for damages, including any direct, indirect, special,
175
+ incidental, or consequential damages of any character arising as a
176
+ result of this License or out of the use or inability to use the
177
+ Work (including but not limited to damages for loss of goodwill,
178
+ work stoppage, computer failure or malfunction, or any and all
179
+ other commercial damages or losses), even if such Contributor
180
+ has been advised of the possibility of such damages.
181
+
182
+ 9. Accepting Warranty or Support. Unless agreed to otherwise,
183
+ no Contributor is required to provide support, warranties,
184
+ indemnities, or other obligations to You. However, if You elect to
185
+ provide support, warranties, indemnities, or other obligations to
186
+ one or more recipients of Covered Software, You may do so only on
187
+ Your own behalf, and not on behalf of any Contributor. You must make
188
+ it absolutely clear that any such warranty, support, indemnity, or
189
+ other obligation is offered by You alone, and You hereby agree to
190
+ indemnify every Contributor for any liability incurred by such
191
+ Contributor as a result of warranty, support, indemnity or other
192
+ obligation You offer.
193
+
194
+ END OF TERMS AND CONDITIONS
195
+
196
+ APPENDIX: How to apply the Apache License to your work.
197
+
198
+ To apply the Apache License to your work, attach the following
199
+ boilerplate notice, with the fields enclosed by brackets "[]"
200
+ replaced with your own identifying information. (Don't include
201
+ the brackets!) The text should be enclosed in the appropriate
202
+ comment syntax for the file format. We also recommend that a
203
+ file or class name and description of purpose be included on the
204
+ same "printed page" as the copyright notice for easier
205
+ identification within third-party archives.
206
+
207
+ Copyright 2026 DataKit, LLC
208
+
209
+ Licensed under the Apache License, Version 2.0 (the "License");
210
+ you may not use this file except in compliance with the License.
211
+ You may obtain a copy of the License at
212
+
213
+ http://www.apache.org/licenses/LICENSE-2.0
214
+
215
+ Unless required by applicable law or agreed to in writing, software
216
+ distributed under the License is distributed on an "AS IS" BASIS,
217
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
218
+ See the License for the specific language governing permissions and
219
+ limitations under the License.
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: grpcreflect-py
3
+ Version: 0.1.0
4
+ Summary: An idiomatic Python implementation of gRPC Server Reflection compatible with ConnectRPC
5
+ Author: Jordan Fowler
6
+ Author-email: Jordan Fowler <jordan@withdatakit.com>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Requires-Dist: connectrpc>=0.12.1
10
+ Requires-Dist: protobuf-py>=0.5.0
11
+ Requires-Python: >=3.12
12
+ Description-Content-Type: text/markdown
13
+
14
+ # grpcreflect-py
15
+
16
+ An idiomatic Python implementation of the [gRPC Server Reflection
17
+ protocol][grpc-reflection] (`grpc.reflection.v1` and
18
+ `grpc.reflection.v1alpha`), built on [`protobuf-py`][protobuf-py] and
19
+ [`connectrpc`][connect-python]. Modeled on Buf's Go reference
20
+ implementation, [`grpcreflect-go`][grpcreflect-go].
21
+
22
+ Since the reflection services here are just `ConnectASGIApplication`s like
23
+ any other, they work over whichever of `connectrpc`'s protocols your own
24
+ services already speak -- Connect, gRPC, and gRPC-Web -- with no extra
25
+ configuration.
26
+
27
+ [grpc-reflection]: https://github.com/grpc/grpc/blob/master/doc/server-reflection.md
28
+ [protobuf-py]: https://github.com/bufbuild/protobuf-py
29
+ [connect-python]: https://github.com/connectrpc/connect-py
30
+ [grpcreflect-go]: https://github.com/connectrpc/grpcreflect-go
31
+
32
+ ## Install
33
+
34
+ ```sh
35
+ uv add grpcreflect-py
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ `mount_reflection_handlers()` takes the same `ConnectASGIApplication`
41
+ instances you're already mounting for your own services, derives a registry
42
+ from their descriptors, and returns them alongside ready-to-mount v1 and
43
+ v1alpha reflection applications:
44
+
45
+ ```python
46
+ from starlette.applications import Starlette
47
+ from starlette.routing import Mount
48
+ from grpcreflect.server import mount_reflection_handlers
49
+
50
+ from example.greet import GreetServiceImpl
51
+ from example.gen.greet.v1.greet_connect import GreetServiceASGIApplication
52
+
53
+ app = Starlette(
54
+ routes=[
55
+ Mount(a.path, app=a)
56
+ for a in mount_reflection_handlers(
57
+ GreetServiceASGIApplication(GreetServiceImpl())
58
+ )
59
+ ]
60
+ )
61
+ ```
62
+
63
+ `ServerReflectionInfo` is a bidirectional streaming RPC, which requires an
64
+ HTTP/2-capable ASGI server. As of this writing, [`pyvoy`][pyvoy] is the
65
+ server most reliably passing the Connect conformance suite's HTTP/2 and
66
+ bidi-streaming tests, so it's the recommended way to serve `app` above:
67
+
68
+ ```python
69
+ import asyncio
70
+ import pyvoy
71
+
72
+ async def main() -> None:
73
+ server = pyvoy.PyvoyServer("myapp:app", port=8080)
74
+ await server.start()
75
+ await server.wait()
76
+
77
+ asyncio.run(main())
78
+ ```
79
+
80
+ You aren't required to use `pyvoy` -- any ASGI server with working HTTP/2
81
+ and bidi-streaming support will do -- but not every ASGI server reliably
82
+ supports both today.
83
+
84
+ [pyvoy]: https://github.com/curioswitch/pyvoy
85
+
86
+ ## Client
87
+
88
+ `Client` speaks gRPC Server Reflection against a server, preferring v1 and
89
+ falling back to v1alpha automatically the first time it discovers v1 isn't
90
+ implemented. `new_stream()` opens a `ClientStream`, which pins a sequence of
91
+ calls to one open stream so they're all answered by a single, consistent
92
+ view of the server's schema:
93
+
94
+ ```python
95
+ import asyncio
96
+
97
+ from grpcreflect.client import Client
98
+
99
+
100
+ async def main() -> None:
101
+ async with Client("http://localhost:8080") as client, client.new_stream() as stream:
102
+ print(await stream.list_services())
103
+
104
+ for descriptor in await stream.file_containing_symbol("greet.v1.GreetService"):
105
+ print(descriptor.name)
106
+
107
+
108
+ asyncio.run(main())
109
+ ```
110
+
111
+ ## Development
112
+
113
+ ```sh
114
+ uv run -- buf generate # regenerate src/grpcreflect/_gen from the upstream schema
115
+ uv run pytest
116
+ ```
@@ -0,0 +1,103 @@
1
+ # grpcreflect-py
2
+
3
+ An idiomatic Python implementation of the [gRPC Server Reflection
4
+ protocol][grpc-reflection] (`grpc.reflection.v1` and
5
+ `grpc.reflection.v1alpha`), built on [`protobuf-py`][protobuf-py] and
6
+ [`connectrpc`][connect-python]. Modeled on Buf's Go reference
7
+ implementation, [`grpcreflect-go`][grpcreflect-go].
8
+
9
+ Since the reflection services here are just `ConnectASGIApplication`s like
10
+ any other, they work over whichever of `connectrpc`'s protocols your own
11
+ services already speak -- Connect, gRPC, and gRPC-Web -- with no extra
12
+ configuration.
13
+
14
+ [grpc-reflection]: https://github.com/grpc/grpc/blob/master/doc/server-reflection.md
15
+ [protobuf-py]: https://github.com/bufbuild/protobuf-py
16
+ [connect-python]: https://github.com/connectrpc/connect-py
17
+ [grpcreflect-go]: https://github.com/connectrpc/grpcreflect-go
18
+
19
+ ## Install
20
+
21
+ ```sh
22
+ uv add grpcreflect-py
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ `mount_reflection_handlers()` takes the same `ConnectASGIApplication`
28
+ instances you're already mounting for your own services, derives a registry
29
+ from their descriptors, and returns them alongside ready-to-mount v1 and
30
+ v1alpha reflection applications:
31
+
32
+ ```python
33
+ from starlette.applications import Starlette
34
+ from starlette.routing import Mount
35
+ from grpcreflect.server import mount_reflection_handlers
36
+
37
+ from example.greet import GreetServiceImpl
38
+ from example.gen.greet.v1.greet_connect import GreetServiceASGIApplication
39
+
40
+ app = Starlette(
41
+ routes=[
42
+ Mount(a.path, app=a)
43
+ for a in mount_reflection_handlers(
44
+ GreetServiceASGIApplication(GreetServiceImpl())
45
+ )
46
+ ]
47
+ )
48
+ ```
49
+
50
+ `ServerReflectionInfo` is a bidirectional streaming RPC, which requires an
51
+ HTTP/2-capable ASGI server. As of this writing, [`pyvoy`][pyvoy] is the
52
+ server most reliably passing the Connect conformance suite's HTTP/2 and
53
+ bidi-streaming tests, so it's the recommended way to serve `app` above:
54
+
55
+ ```python
56
+ import asyncio
57
+ import pyvoy
58
+
59
+ async def main() -> None:
60
+ server = pyvoy.PyvoyServer("myapp:app", port=8080)
61
+ await server.start()
62
+ await server.wait()
63
+
64
+ asyncio.run(main())
65
+ ```
66
+
67
+ You aren't required to use `pyvoy` -- any ASGI server with working HTTP/2
68
+ and bidi-streaming support will do -- but not every ASGI server reliably
69
+ supports both today.
70
+
71
+ [pyvoy]: https://github.com/curioswitch/pyvoy
72
+
73
+ ## Client
74
+
75
+ `Client` speaks gRPC Server Reflection against a server, preferring v1 and
76
+ falling back to v1alpha automatically the first time it discovers v1 isn't
77
+ implemented. `new_stream()` opens a `ClientStream`, which pins a sequence of
78
+ calls to one open stream so they're all answered by a single, consistent
79
+ view of the server's schema:
80
+
81
+ ```python
82
+ import asyncio
83
+
84
+ from grpcreflect.client import Client
85
+
86
+
87
+ async def main() -> None:
88
+ async with Client("http://localhost:8080") as client, client.new_stream() as stream:
89
+ print(await stream.list_services())
90
+
91
+ for descriptor in await stream.file_containing_symbol("greet.v1.GreetService"):
92
+ print(descriptor.name)
93
+
94
+
95
+ asyncio.run(main())
96
+ ```
97
+
98
+ ## Development
99
+
100
+ ```sh
101
+ uv run -- buf generate # regenerate src/grpcreflect/_gen from the upstream schema
102
+ uv run pytest
103
+ ```
@@ -0,0 +1,54 @@
1
+ [project]
2
+ name = "grpcreflect-py"
3
+ version = "0.1.0"
4
+ description = "An idiomatic Python implementation of gRPC Server Reflection compatible with ConnectRPC"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.12"
9
+ dependencies = [
10
+ "connectrpc>=0.12.1",
11
+ "protobuf-py>=0.5.0",
12
+ ]
13
+
14
+ [[project.authors]]
15
+ name = "Jordan Fowler"
16
+ email = "jordan@withdatakit.com"
17
+
18
+ [build-system]
19
+ requires = ["uv_build>=0.12.17,<0.13.0"]
20
+ build-backend = "uv_build"
21
+
22
+ [dependency-groups]
23
+ dev = [
24
+ "buf-bin>=1.73.0",
25
+ "protoc-gen-connectrpc>=0.12.1",
26
+ "protoc-gen-py>=0.5.0",
27
+ "pytest>=9.1.1",
28
+ "pytest-asyncio>=1.4.0",
29
+ "pyvoy>=1.1.0",
30
+ "ruff>=0.17.3",
31
+ "starlette>=1.6.0",
32
+ ]
33
+
34
+ [tool.pytest.ini_options]
35
+ asyncio_mode = "auto"
36
+
37
+ [tool.uv.build-backend]
38
+ module-name = ["grpcreflect"]
39
+
40
+ [tool.ruff]
41
+ extend-exclude = ["src/grpcreflect/_gen"]
42
+
43
+ [tool.ruff.lint]
44
+ select = [
45
+ "E",
46
+ "F",
47
+ "I",
48
+ "UP",
49
+ "B",
50
+ ]
51
+ ignore = [
52
+ "E501",
53
+ "UP046",
54
+ ]
@@ -0,0 +1,39 @@
1
+ [project]
2
+ name = "grpcreflect-py"
3
+ version = "0.1.0"
4
+ description = "An idiomatic Python implementation of gRPC Server Reflection compatible with ConnectRPC"
5
+ readme = "README.md"
6
+ authors = [{ name = "Jordan Fowler", email = "jordan@withdatakit.com" }]
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE"]
9
+ requires-python = ">=3.12"
10
+ dependencies = ["connectrpc>=0.12.1", "protobuf-py>=0.5.0"]
11
+
12
+ [build-system]
13
+ requires = ["uv_build>=0.12.17,<0.13.0"]
14
+ build-backend = "uv_build"
15
+
16
+ [dependency-groups]
17
+ dev = [
18
+ "buf-bin>=1.73.0",
19
+ "protoc-gen-connectrpc>=0.12.1",
20
+ "protoc-gen-py>=0.5.0",
21
+ "pytest>=9.1.1",
22
+ "pytest-asyncio>=1.4.0",
23
+ "pyvoy>=1.1.0",
24
+ "ruff>=0.17.3",
25
+ "starlette>=1.6.0",
26
+ ]
27
+
28
+ [tool.pytest.ini_options]
29
+ asyncio_mode = "auto"
30
+
31
+ [tool.uv.build-backend]
32
+ module-name = ["grpcreflect"]
33
+
34
+ [tool.ruff]
35
+ extend-exclude = ["src/grpcreflect/_gen"]
36
+
37
+ [tool.ruff.lint]
38
+ select = ["E", "F", "I", "UP", "B"]
39
+ ignore = ["E501", "UP046"]
@@ -0,0 +1,14 @@
1
+ """An idiomatic Python implementation of gRPC Server Reflection."""
2
+
3
+ from grpcreflect.client import Client, ClientStream
4
+ from grpcreflect.reflector import ReflectionSchema, Reflector, ReflectorOptions
5
+ from grpcreflect.server import mount_reflection_handlers
6
+
7
+ __all__ = [
8
+ "Client",
9
+ "ClientStream",
10
+ "ReflectionSchema",
11
+ "Reflector",
12
+ "ReflectorOptions",
13
+ "mount_reflection_handlers",
14
+ ]
@@ -0,0 +1 @@
1
+ from __future__ import annotations
@@ -0,0 +1 @@
1
+ from __future__ import annotations
@@ -0,0 +1 @@
1
+ from __future__ import annotations
@@ -0,0 +1 @@
1
+ from __future__ import annotations