gRPC typing stubs for Python

Overview
Comments
  • Consider using pytest-mypy-plugins

    Consider using pytest-mypy-plugins

    Hi! Thanks for this awesome project!

    I am TypedDjango team member, we maintain types for, well, django. And we do pretty much the same job.

    For example, we test our types like so: tests/. We even created a tool called pytest-mypy-plugins (announcing post) to help us with this task. Maybe it will be also helpful to you as well.

    That's how the simplest test looks like:

    - case: compose_two_wrong_functions
      main: |
        from returns.functions import compose
    
        def first(num: int) -> float:
            return float(num)
    
        def second(num: float) -> str:
            return str(num)
    
        reveal_type(compose(first, second)(1))  # N: builtins.str*
    

    Ask any questions you have!

    P.S. This project was listed in awesome-python-stubs list.

    opened by sobolevn 13
  • No stubs for client stubs?

    No stubs for client stubs?

    Hey, thanks a ton for these stubs :)

    I have recently added some client implementation to my server code (it's a gRPC server that queries another gRPC server), meaning that it makes use of the client stub of that other server.

    Now mypy started complaining about

    error: Call to untyped function "ServiceStub" in typed context  [no-untyped-call]
    

    This error is happening on the line in which I instantiate my client:

    channel = grpc.insecure_channel("some-address:8000")
    client = ServiceStub(channel)  # This line is triggering the error
    response = client.SomeMethod(request)
    

    I had a quick look into this repo to check if I was simply missing something, but I did indeed not find any stubs for the client stubs.

    Are they missing? Is there a good way for me to get rid of that error other than ignoring it?

    opened by LanDinh 5
  • Added missing grpc.health.v1 stubs

    Added missing grpc.health.v1 stubs

    Was having issues importing grpc_health stubs.

    Example:

    from grpc_health.v1.health_pb2 import HealthCheckRequest
    from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server
    

    All files are generated using mypy-protobuf.

    opened by LiamAttClarke 4
  • Make CallFuture `Awaitable`

    Make CallFuture `Awaitable`

    Description

    Currently, you are unable to call await on the result of asyncio calls on client stubs. This is because we define our own Future and CallFuture objects, that are not marked as Awaitable -- so mypy thinks they cannot be used with await.

    Original problem

    I generated some stubs using mypy-protobuf. I also have grpc-stubs==1.24.6 installed.

    My stub looks like this:

    class FooServiceStub:
       ...
        ListFoo: grpc.UnaryUnaryMultiCallable[
            global___ListFooRequest,
            global___ListFooResponse] = ...
    

    Later, when I try to use this like so:

    client = FooServiceStub(...)
    req = ListFooRequest()
    result = await client.ListFoo(req).future()
    

    However this yields a mypy error: Incompatible types in "await" (actual type "CallFuture[ListFooResponse]", expected type "Awaitable[Any]").

    Alternate Solutions

    Awaitable could be added to the base Future type instead of to CallFuture.

    opened by slessans 3
  • can mypy be optional dependency?

    can mypy be optional dependency?

    Hi, thanks for this awesome project, it really helps a lot. As the title say, can mypy be an install dependency? In many scenarios, pyi stubs are used for augmenting Pycharm auto-completement instead of type-check jobs, without installing mypy, tens of megabytes of packages will be reduced from the virtual env.

    opened by jizhilong 2
  • Fix aio with `Any`s

    Fix aio with `Any`s

    This attempts to fix some of the asyncio issues by converting metadata to Anys. Not particularly proud of the solution, but may be an OK band-aid in the meantime if it can get things unblocked. All the rest of the code is the original code from https://github.com/shabbyrobe/grpc-stubs/pull/15

    opened by slessans 2
  • Distribution doesn't include py.typed files.

    Distribution doesn't include py.typed files.

    The current distribution package doesn't include the py.typed files in this repo. This isn't a blocker, as they aren't strictly required in a stub-only package. However this may be unexpected?

    opened by asford 2
  • Add stubs for grpc.aio

    Add stubs for grpc.aio

    The grpc.aio module has good type annotation, but without these stubs existing mypy falls over when using it whilst the gRPC stubs in this repository are installed.

    The stubs themselves are autogenerated with stubgen and tidied up by hand.

    opened by ColdrickSotK 2
  • Refine ClientCallDetails fields

    Refine ClientCallDetails fields

    All fields in ClientCallDetails are optional except for method. This object encapsulates arguments passed to rpc method calls on client stubs, for which only the request object is required.

    Reference: https://github.com/grpc/grpc/blob/master@{2019-12-05}/src/python/grpcio/grpc/_interceptor.py#L227-L234

    opened by josephharrington 2
  • Missing grpc StatusCode

    Missing grpc StatusCode

    Description of issue

    Problem: Status code "OUT_OF_RANGE" is defined in google.rpc but is not present in grpc-stubs.

    Solution: Add + OUT_OF_RANGE = ... to grpc-stubs/__init__.pyi

    Minimum Reproducible Example

    Mypy fails with no attribute "OUT_OF_RANGE":

    example.py

    #check with mypy example.py

    import grpc

    status1 = grpc.StatusCode.CANCELLED # Okay status2 = grpc.StatusCode.OUT_OF_RANGE # Error!

    opened by HawkeyeCov 1
  • server() expects list of ServerInterceptor

    server() expects list of ServerInterceptor

    The current typehint wants a list of various client interceptors, when in reality it should be a list of ServerInterceptor as per the docs:

    interceptors: An optional list of ServerInterceptor objects that observe and optionally manipulate the incoming RPCs before handing them over to handlers. The interceptors are given control in the order they are specified. This is an EXPERIMENTAL API.

    opened by jyggen 1
  • Typing of HealthServicer.set

    Typing of HealthServicer.set

    Hi, Just curious about a change in the last release (1.24.9)

    After this change, I'm finding it hard to set the status of services without a mypy error.

    The code straight from the grpc examples https://github.com/grpc/grpc/blob/master/examples/python/xds/server.py:

        # Mark all services as healthy.
        health_pb2_grpc.add_HealthServicer_to_server(health_servicer, server)
        for service in services:
            health_servicer.set(service, health_pb2.HealthCheckResponse.SERVING)
    

    Now causes a mypy error of:

    Argument 2 to "set" of "HealthServicer" has incompatible type "ValueType"; expected "ServingStatus"  [arg-type]
    

    I think argument 2 should be a HealthCheckResponse.ServingStatus.ValueType ? Defined in grpc_health-stubs/v1/health.pyi

    This never used to cause a problem with health_pb2 stubs missing, but now they are there I am getting this error. Or if I am wrong about that arguments type, how do I now set a servicer status without a mypy error?

    opened by jonyscathe 6
  • No stubs for `aio`

    No stubs for `aio`

    Is there any plans to include stubs for grpc.aio? I love this package but it doesn't seem to provide the aio features. I am more than willing to help out if necessary. I also saw a discussion about this in #15, but not sure what's happening here.

    opened by damodar-anthem 8
  • Typeshed

    Typeshed

    Hello 👋. I found this repo and this works really well with mypy. I was wondering if you had any plans of including this in typeshed so that it is automatically included in mypy. I am not sure the exact amount of work needed but it does not sound like a lot. If you do not have the time, I might be able to try to do it as well if you want! Thank you for making this either way!

    opened by snallapa 6
Owner
Blake Williams
I code for fun. I have been known to code for food. I typically work with Go, TypeScript, Python or C. I enjoy Go a lot. I have worked with lots of other stuff.
Blake Williams
Medusa is a cross-platform agent compatible with both Python 3.8 and Python 2.7.

Medusa Medusa is a cross-platform agent compatible with both Python 3.8 and Python 2.7. Installation To install Medusa, you'll need Mythic installed o

Mythic Agents 123 Nov 9, 2022
ProtOSINT is a Python script that helps you investigate Protonmail accounts and ProtonVPN IP addresses

ProtOSINT ProtOSINT is a Python script that helps you investigate ProtonMail accounts and ProtonVPN IP addresses. Description This tool can help you i

pixelbubble 249 Dec 23, 2022
A Python tool used to automate the execution of the following tools : Nmap , Nikto and Dirsearch but also to automate the report generation during a Web Penetration Testing

?? WebMap A Python tool used to automate the execution of the following tools : Nmap , Nikto and Dirsearch but also to automate the report generation

Iliass Alami Qammouri 274 Jan 1, 2023
msgspec is a fast and friendly implementation of the MessagePack protocol for Python 3.8+

msgspec msgspec is a fast and friendly implementation of the MessagePack protocol for Python 3.8+. In addition to serialization/deserializat

Jim Crist-Harif 414 Jan 6, 2023
Light, simple RPC framework for Python

Agileutil是一个Python3 RPC框架。基于微服务架构,封装了rpc/http/orm/log等常用组件,提供了简洁的API,开发者可以很快上手,快速进行业务开发。

null 16 Nov 22, 2022
Minimal, self-hosted, 0-config alternative to ngrok. Caddy+OpenSSH+50 lines of Python.

If you have a webserver running on one computer (say your development laptop), and you want to expose it securely (ie HTTPS) via a public URL, SirTunnel allows you to easily do that.

Anders Pitman 423 Jan 2, 2023
NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks.

NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks.

NetworkX 12k Jan 2, 2023
A Python library to ease the integration with the Beem Africa (SMS, AIRTIME, OTP, 2WAY-SMS, BPAY, USSD)

python-client A Python library to easy the integration with the Beem Africa SMS Gateway Features to be Implemented Airtime OTP SMS Two way SMS USSD Bp

Beem Africa 24 Oct 29, 2022
Python port of proxy-www (https://github.com/justjavac/proxy-www)

proxy-www.py Python port of proxy-www (https://github.com/justjavac/proxy-www). Implemented additional functionalities! How to install pip install pro

Minjun Kim (Lapis0875) 20 Dec 8, 2021
DNSStager is an open-source project based on Python used to hide and transfer your payload using DNS.

What is DNSStager? DNSStager is an open-source project based on Python used to hide and transfer your payload using DNS. DNSStager will create a malic

Askar 547 Dec 20, 2022
telnet implementation over TCP socket with python

This a P2P implementation of telnet. This program transfers data on TCP sockets as plain text

null 10 May 19, 2022
Network-Shredder is a python based NIDS.

Network-Shredder is a python based NIDS.

Oussama RAHALI 9 Dec 13, 2022
Python 3 tool for finding unclaimed groups on Roblox. Supports multi-threading, multi-processing and HTTP proxies.

roblox-group-scanner Python 3 tool for finding unclaimed groups on Roblox. Supports multi-threading, multi-processing and HTTP proxies. Usage usage: s

h0nda 43 May 11, 2022
An ftp syncing python package that I use to sync pokemon saves between my hacked 3ds running ftpd and my server

Sync file pairs over ftp and apply patches to them. Useful for using ftpd to transfer ROM save files to and from your DS if you also play on an emulator. Setup a cron job to check for your DS's ftp server periodically to setup automatic syncing. Untested on windows. It may just work out of the box, unsure though.

null 17 Jan 4, 2023
A Python library to utilize AWS API Gateway's large IP pool as a proxy to generate pseudo-infinite IPs for web scraping and brute forcing.

A Python library to utilize AWS API Gateway's large IP pool as a proxy to generate pseudo-infinite IPs for web scraping and brute forcing.

George O 929 Jan 1, 2023
GlokyPortScannar is a really fast tool to scan TCP ports implemented in Python.

GlokyPortScannar is a really fast tool to scan TCP ports implemented in Python. Installation: This program requires Python 3.9. Linux

gl0ky 5 Jun 25, 2022
Python Scrcpy Client - allows you to view and control android device in realtime

Python Scrcpy Client This package allows you to view and control android device in realtime. Note: This gif is compressed and experience lower quality

LengYue 126 Jan 2, 2023
pyWhisker is a Python equivalent of the original Whisker made by Elad Shamir and written in C#.

PyWhisker pyWhisker is a Python equivalent of the original Whisker made by Elad Shamir and written in C#. This tool allows users to manipulate the msD

Shutdown 325 Jan 8, 2023
Wifi-Jamming is a simple, yet highly effective method of causing a DoS on a wireless implemented using python pyqt5.

pyqt5-linux-wifi-jamming-tool Linux-Wifi-Jamming is a simple GUI tool, yet highly effective method of causing a DoS on a wireless implemented using py

lafesa 8 Dec 5, 2022