mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-18 21:35:24 +01:00
docs: add instructions to generate type hints (#8025)
* Add instructions to generate type hints Use mypy to generate .pyi files as well. These files are useful for type hinting in IDEs. * Update python.md fix lines that got swapped in copy-paste * remove mypy mypy is not a dependency
This commit is contained in:
parent
dce4bb16be
commit
80bfd17cf2
@ -20,7 +20,7 @@ file in Python before you can use it to communicate with lnd.
|
||||
3. Install dependencies (googleapis-common-protos is required due to the use of
|
||||
google/api/annotations.proto)
|
||||
```shell
|
||||
lnd $ pip install grpcio grpcio-tools googleapis-common-protos
|
||||
lnd $ pip install grpcio grpcio-tools googleapis-common-protos mypy-protobuf
|
||||
```
|
||||
4. Clone the google api's repository (required due to the use of
|
||||
google/api/annotations.proto)
|
||||
@ -35,12 +35,11 @@ file in Python before you can use it to communicate with lnd.
|
||||
```
|
||||
6. Compile the proto file
|
||||
```shell
|
||||
lnd $ python -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. lightning.proto
|
||||
lnd $ python -m grpc_tools.protoc --proto_path=googleapis:. --mypy_out=. --python_out=. --grpc_python_out=. lightning.proto
|
||||
```
|
||||
|
||||
After following these steps, two files `lightning_pb2.py` and
|
||||
`lightning_pb2_grpc.py` will be generated. These files will be imported in your
|
||||
project anytime you use Python gRPC.
|
||||
After following these steps, three files `lightning_pb2.py`,
|
||||
`lightning_pb2_grpc.py` and `lightning_pb2.pyi` will be generated. These files will be imported in your project anytime you use Python gRPC.
|
||||
|
||||
### Generating RPC modules for subservers
|
||||
|
||||
@ -50,11 +49,11 @@ generate the python modules for them.
|
||||
For example, if you want to generate the RPC modules for the `Router` subserver
|
||||
(located/defined in `routerrpc/router.proto`), you need to run the following two
|
||||
extra steps (after completing all 6 step described above) to get the
|
||||
`router_pb2.py` and `router_pb2_grpc.py`:
|
||||
`router_pb2.py`, `router_pb2_grpc.py` and `router_pb2.pyi`:
|
||||
|
||||
```shell
|
||||
lnd $ curl -o router.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/routerrpc/router.proto
|
||||
lnd $ python -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. router.proto
|
||||
lnd $ python -m grpc_tools.protoc --proto_path=googleapis:. --mypy_out=. --python_out=. --grpc_python_out=. router.proto
|
||||
```
|
||||
|
||||
### Imports and Client
|
||||
@ -221,4 +220,4 @@ Here is an example of a working format that allows for use of a reserved word `g
|
||||
```
|
||||
args = {'global': True, 'base_fee_msat': 1000, 'fee_rate': 0.000001, 'time_lock_delta': 40}
|
||||
stub.UpdateChannelPolicy(ln.PolicyUpdateRequest(**args))
|
||||
```
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user