Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions stubs/grpcio/@tests/test_cases/check_experimental.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from typing_extensions import assert_type

import grpc.experimental.gevent as grpc_gevent

assert_type(grpc_gevent.init_gevent(), None)
Comment on lines +1 to +5
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this file - test cases are only needed for weird and/or complicated cases that might regress in the future. This test basically repeats the signature (and a particularly trivial one at that :-)), so it isn't really necessary

1 change: 1 addition & 0 deletions stubs/grpcio/grpc/experimental/__init__.pyi
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just delete this file, since partial-stub = true, and no direct members of this module are being stubbed. But if that ends up not being the case, you need to add the following to account for the fact that not all public functions are part of the stub file:

def __getattr__(name: str): ...  # incomplete module

The partial-stub marker in METADATA.toml only tells type checkers that whole modules are missing, not that modules that do exist might be incomplete. That's what the __getattr__ does. You may also need to add this module to pyrightconfig.stricter.json if not already covered

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import gevent as gevent
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runtime doesn't actually re-export gevent, so e.g. this fails:

$ uv run -w grpcio python3 -c 'import grpc.experimental; grpc.experimental.gevent'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import grpc.experimental; grpc.experimental.gevent
                              ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'grpc.experimental' has no attribute 'gevent'

Type checkers understand submodule relationships, so we don't need to add anything here in order for them to understand that the gevent submodule exists.

Suggested change
from . import gevent as gevent

1 change: 1 addition & 0 deletions stubs/grpcio/grpc/experimental/gevent.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def init_gevent() -> None: ...
Loading