pydantic-rpc 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl
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.
- pydantic_rpc/__init__.py +9 -0
- pydantic_rpc/core.py +15 -10
- {pydantic_rpc-0.4.0.dist-info → pydantic_rpc-0.5.0.dist-info}/METADATA +9 -7
- pydantic_rpc-0.5.0.dist-info/RECORD +8 -0
- {pydantic_rpc-0.4.0.dist-info → pydantic_rpc-0.5.0.dist-info}/WHEEL +1 -1
- pydantic_rpc-0.5.0.dist-info/entry_points.txt +2 -0
- pydantic_rpc-0.4.0.dist-info/RECORD +0 -7
- {pydantic_rpc-0.4.0.dist-info → pydantic_rpc-0.5.0.dist-info}/licenses/LICENSE +0 -0
pydantic_rpc/__init__.py
CHANGED
pydantic_rpc/core.py
CHANGED
|
@@ -606,7 +606,7 @@ def comment_out(docstr: str) -> tuple[str, ...]:
|
|
|
606
606
|
if docstr.startswith("Usage docs: https://docs.pydantic.dev/2.10/concepts/models/"):
|
|
607
607
|
return tuple()
|
|
608
608
|
|
|
609
|
-
return tuple(
|
|
609
|
+
return tuple("//" if line == "" else f"// {line}" for line in docstr.split("\n"))
|
|
610
610
|
|
|
611
611
|
|
|
612
612
|
def indent_lines(lines, indentation=" "):
|
|
@@ -1330,14 +1330,19 @@ class ConnecpyASGIApp:
|
|
|
1330
1330
|
await self._app(scope, receive, send)
|
|
1331
1331
|
|
|
1332
1332
|
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
"""
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1333
|
+
def main():
|
|
1334
|
+
import argparse
|
|
1335
|
+
|
|
1336
|
+
parser = argparse.ArgumentParser(description="Generate and compile proto files.")
|
|
1337
|
+
parser.add_argument("py_file", type=str, help="The Python file containing the service class.")
|
|
1338
|
+
parser.add_argument("class_name", type=str, help="The name of the service class.")
|
|
1339
|
+
args = parser.parse_args()
|
|
1340
|
+
|
|
1341
|
+
module_name = os.path.splitext(basename(args.py_file))[0]
|
|
1341
1342
|
module = importlib.import_module(module_name)
|
|
1342
|
-
klass = getattr(module, class_name)
|
|
1343
|
+
klass = getattr(module, args.class_name)
|
|
1343
1344
|
generate_and_compile_proto(klass())
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
if __name__ == "__main__":
|
|
1348
|
+
main()
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic-rpc
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: A Python library for building gRPC/ConnectRPC services with Pydantic models.
|
|
5
5
|
Author: Yasushi Itoh
|
|
6
|
+
License-File: LICENSE
|
|
6
7
|
Requires-Python: >=3.11
|
|
7
|
-
Requires-Dist: connecpy>=1.2.
|
|
8
|
+
Requires-Dist: connecpy>=1.2.1
|
|
8
9
|
Requires-Dist: grpcio-health-checking>=1.56.2
|
|
9
10
|
Requires-Dist: grpcio-reflection>=1.56.2
|
|
10
11
|
Requires-Dist: grpcio-tools>=1.56.2
|
|
@@ -229,7 +230,7 @@ app.mount(Greeter())
|
|
|
229
230
|
PydanticRPC also partially supports Connect-RPC via connecpy. Check out “greeting_connecpy.py” for an example:
|
|
230
231
|
|
|
231
232
|
```bash
|
|
232
|
-
|
|
233
|
+
uv run greeting_connecpy.py
|
|
233
234
|
```
|
|
234
235
|
|
|
235
236
|
This will launch a Connecpy-based ASGI application that uses the same Pydantic models to serve Connect-RPC requests.
|
|
@@ -403,16 +404,17 @@ if __name__ == "__main__":
|
|
|
403
404
|
|
|
404
405
|
TODO
|
|
405
406
|
|
|
406
|
-
### 🗄️ Protobuf file generation
|
|
407
|
+
### 🗄️ Protobuf file and code (Python files) generation
|
|
407
408
|
|
|
408
|
-
|
|
409
|
+
Youcan genereate protobuf files and code for a given module and a specified class using `pydantic-rpc` CLI command:
|
|
409
410
|
|
|
410
411
|
```bash
|
|
411
|
-
|
|
412
|
+
pydantic-rpc a_module.py aClassName
|
|
412
413
|
```
|
|
413
414
|
|
|
414
415
|
Using this generated proto file and tools as `protoc`, `buf` and `BSR`, you could generate code for any desired language other than Python.
|
|
415
416
|
|
|
417
|
+
|
|
416
418
|
## 📖 Data Type Mapping
|
|
417
419
|
|
|
418
420
|
| Python Type | Protobuf Type |
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pydantic_rpc/__init__.py,sha256=oomSVGmh_zddQQaphQt1L2xSVh9dD1LVyaAq1cN1FW4,231
|
|
2
|
+
pydantic_rpc/core.py,sha256=7RPQEhqzzUIqm6IYLSsKYPIHV1_VV7UvCehPAAkUuJ4,48085
|
|
3
|
+
pydantic_rpc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
pydantic_rpc-0.5.0.dist-info/METADATA,sha256=xBMHL0pmboi5BAkREyu-LtlhXJ_drfj3jOwUbOaHlKE,12060
|
|
5
|
+
pydantic_rpc-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
6
|
+
pydantic_rpc-0.5.0.dist-info/entry_points.txt,sha256=LeZJ6UN-fhjKrEGkcmsAAKuA-fIe7MpvzKMPSZfi0NE,56
|
|
7
|
+
pydantic_rpc-0.5.0.dist-info/licenses/LICENSE,sha256=Y6jkAm2VqPqoGIGQ-mEQCecNfteQ2LwdpYhC5XiH_cA,1069
|
|
8
|
+
pydantic_rpc-0.5.0.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
pydantic_rpc/__init__.py,sha256=AWYjSmYQcMqsqGmGK4k-pQQhX6RBBgkTvNcQtCtsctU,113
|
|
2
|
-
pydantic_rpc/core.py,sha256=6NMTtS8cKNjPN5cBvd_XLU6h1oMZ6EqAHz-HGLnJpD0,47939
|
|
3
|
-
pydantic_rpc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
pydantic_rpc-0.4.0.dist-info/METADATA,sha256=FOVo-T-PCD0Sxh__B9cVaZpXb6XfUBOPmFIW0hP1v58,11993
|
|
5
|
-
pydantic_rpc-0.4.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
6
|
-
pydantic_rpc-0.4.0.dist-info/licenses/LICENSE,sha256=Y6jkAm2VqPqoGIGQ-mEQCecNfteQ2LwdpYhC5XiH_cA,1069
|
|
7
|
-
pydantic_rpc-0.4.0.dist-info/RECORD,,
|
|
File without changes
|