Skip to content

Commit c89ee56

Browse files
authored
Move to types-grpcio (#703)
* Move to types-grpci o from typeshed because grpc-stubs has been archived Signed-off-by: Aidan Jensen <aidandj.github@gmail.com> * update test output from mypy update Signed-off-by: Aidan Jensen <aidandj.github@gmail.com> --------- Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
1 parent 505e3a0 commit c89ee56

16 files changed

+89
-88
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Protobuf <6.32 still had the edition enums and field options, so it *should* still work. But is untested
88
- Add support for editions (up to 2024)
99
- Add `generate_concrete_servicer_stubs` option to generate concrete instead of abstract servicer stubs
10+
- Switch to types-grpcio instead of no longer maintained grpc-stubs
1011
- Add `_HasFieldArgType` and `_ClearFieldArgType` aliases to allow for typing field manipulation functions
1112
- Add `_WhichOneofArgType_<oneof_name>` and `_WhichOneofReturnType_<oneof_name>` type aliases
1213

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Earlier releases might work, but aren't tested
3333

3434
- [grpcio>=1.70](https://pypi.org/project/grpcio/)
3535
- [grpcio-tools>=1.70](https://pypi.org/project/grpcio-tools/)
36-
- [grpc-stubs>=1.53.0.5](https://pypi.org/project/grpc-stubs/)
36+
- [types-grpcio>=1.0.0.20251009](https://pypi.org/project/types-grpcio/)
3737

3838
Other configurations may work, but are not continuously tested currently.
3939
We would be open to expanding this list - file an issue on the issue tracker.
@@ -369,7 +369,7 @@ protoc \
369369
```
370370

371371
Note that generated code for grpc will work only together with code for python and locations should be the same.
372-
If you need stubs for grpc internal code we suggest using this package https://github.com/shabbyrobe/grpc-stubs
372+
If you need stubs for grpc internal code we suggest using this package https://pypi.org/project/types-grpcio/
373373

374374
### `_ClearFieldArgType`, `_WhichOneofArgType_<oneof_name>`, `_WhichOneofReturnType_<oneof_name>` and `_HasFieldArgType` aliases
375375

test/test_grpc_usage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_grpc() -> None:
6464
assert result4.value == "GRPC"
6565

6666
# test future() in MultiCallable
67-
future_test: grpc.CallFuture[dummy_pb2.DummyReply] = client.UnaryUnary.future(request)
67+
future_test: grpc._CallFuture[dummy_pb2.DummyReply] = client.UnaryUnary.future(request)
6868
result5 = future_test.result()
6969
print(result5)
7070
assert result5.value == "grpc"

test_negative/output.expected.3.10

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,22 @@ test_negative/negative.py:204: note: def [_DummyServiceUnaryUnaryType: (Unar
107107
test_negative/negative.py:211: error: "DummyReply" has no attribute "not_exists" [attr-defined]
108108
test_negative/negative.py:212: error: "DummyReply" has no attribute "__iter__" (not iterable) [attr-defined]
109109
test_negative/negative.py:217: error: "DummyReply" has no attribute "not_exists" [attr-defined]
110-
test_negative/negative.py:219: error: "CallIterator[DummyReply]" has no attribute "value" [attr-defined]
110+
test_negative/negative.py:219: error: "_CallIterator[DummyReply]" has no attribute "value" [attr-defined]
111111
test_negative/negative.py:226: error: Argument 1 to "__call__" of "StreamUnaryMultiCallable" has incompatible type "DummyRequest"; expected "Iterator[DummyRequest]" [arg-type]
112112
test_negative/negative.py:228: error: "DummyReply" has no attribute "__iter__" (not iterable) [attr-defined]
113113
test_negative/negative.py:228: error: Argument 1 to "__call__" of "StreamUnaryMultiCallable" has incompatible type "DummyRequest"; expected "Iterator[DummyRequest]" [arg-type]
114114
test_negative/negative.py:231: error: Argument 1 to "__call__" of "StreamStreamMultiCallable" has incompatible type "DummyRequest"; expected "Iterator[DummyRequest]" [arg-type]
115115
test_negative/negative.py:235: error: "DummyReply" has no attribute "not_exists" [attr-defined]
116-
test_negative/negative.py:272: error: Return type "Iterator[DummyReply]" of "UnaryUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "DummyServiceServicer" [override]
117-
test_negative/negative.py:274: error: Argument 1 of "UnaryUnary" is incompatible with supertype "DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
116+
test_negative/negative.py:272: error: Return type "Iterator[DummyReply]" of "UnaryUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer" [override]
117+
test_negative/negative.py:274: error: Argument 1 of "UnaryUnary" is incompatible with supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
118118
test_negative/negative.py:274: note: This violates the Liskov substitution principle
119119
test_negative/negative.py:274: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
120-
test_negative/negative.py:280: error: Return type "DummyReply" of "UnaryStream" incompatible with return type "Iterator[DummyReply] | AsyncIterator[DummyReply]" in supertype "DummyServiceServicer" [override]
121-
test_negative/negative.py:282: error: Argument 1 of "UnaryStream" is incompatible with supertype "DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
120+
test_negative/negative.py:280: error: Return type "DummyReply" of "UnaryStream" incompatible with return type "Iterator[DummyReply] | AsyncIterator[DummyReply]" in supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer" [override]
121+
test_negative/negative.py:282: error: Argument 1 of "UnaryStream" is incompatible with supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
122122
test_negative/negative.py:282: note: This violates the Liskov substitution principle
123123
test_negative/negative.py:282: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
124-
test_negative/negative.py:289: error: Return type "Iterator[DummyReply]" of "StreamUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "DummyServiceServicer" [override]
125-
test_negative/negative.py:291: error: Argument 1 of "StreamUnary" is incompatible with supertype "DummyServiceServicer"; supertype defines the argument type as "_MaybeAsyncIterator[DummyRequest]" [override]
124+
test_negative/negative.py:289: error: Return type "Iterator[DummyReply]" of "StreamUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer" [override]
125+
test_negative/negative.py:291: error: Argument 1 of "StreamUnary" is incompatible with supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer"; supertype defines the argument type as "_MaybeAsyncIterator[DummyRequest]" [override]
126126
test_negative/negative.py:291: note: This violates the Liskov substitution principle
127127
test_negative/negative.py:291: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
128128
test_negative/negative.py:331: error: Argument "implicit_singular" to "Editions2024Test" has incompatible type "None"; expected "str" [arg-type]

test_negative/output.expected.3.10.omit_linenos

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,22 @@ test_negative/negative.py: note: def [_DummyServiceUnaryUnaryType: (UnaryUna
107107
test_negative/negative.py: error: "DummyReply" has no attribute "not_exists" [attr-defined]
108108
test_negative/negative.py: error: "DummyReply" has no attribute "__iter__" (not iterable) [attr-defined]
109109
test_negative/negative.py: error: "DummyReply" has no attribute "not_exists" [attr-defined]
110-
test_negative/negative.py: error: "CallIterator[DummyReply]" has no attribute "value" [attr-defined]
110+
test_negative/negative.py: error: "_CallIterator[DummyReply]" has no attribute "value" [attr-defined]
111111
test_negative/negative.py: error: Argument 1 to "__call__" of "StreamUnaryMultiCallable" has incompatible type "DummyRequest"; expected "Iterator[DummyRequest]" [arg-type]
112112
test_negative/negative.py: error: "DummyReply" has no attribute "__iter__" (not iterable) [attr-defined]
113113
test_negative/negative.py: error: Argument 1 to "__call__" of "StreamUnaryMultiCallable" has incompatible type "DummyRequest"; expected "Iterator[DummyRequest]" [arg-type]
114114
test_negative/negative.py: error: Argument 1 to "__call__" of "StreamStreamMultiCallable" has incompatible type "DummyRequest"; expected "Iterator[DummyRequest]" [arg-type]
115115
test_negative/negative.py: error: "DummyReply" has no attribute "not_exists" [attr-defined]
116-
test_negative/negative.py: error: Return type "Iterator[DummyReply]" of "UnaryUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "DummyServiceServicer" [override]
117-
test_negative/negative.py: error: Argument 1 of "UnaryUnary" is incompatible with supertype "DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
116+
test_negative/negative.py: error: Return type "Iterator[DummyReply]" of "UnaryUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer" [override]
117+
test_negative/negative.py: error: Argument 1 of "UnaryUnary" is incompatible with supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
118118
test_negative/negative.py: note: This violates the Liskov substitution principle
119119
test_negative/negative.py: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
120-
test_negative/negative.py: error: Return type "DummyReply" of "UnaryStream" incompatible with return type "Iterator[DummyReply] | AsyncIterator[DummyReply]" in supertype "DummyServiceServicer" [override]
121-
test_negative/negative.py: error: Argument 1 of "UnaryStream" is incompatible with supertype "DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
120+
test_negative/negative.py: error: Return type "DummyReply" of "UnaryStream" incompatible with return type "Iterator[DummyReply] | AsyncIterator[DummyReply]" in supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer" [override]
121+
test_negative/negative.py: error: Argument 1 of "UnaryStream" is incompatible with supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
122122
test_negative/negative.py: note: This violates the Liskov substitution principle
123123
test_negative/negative.py: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
124-
test_negative/negative.py: error: Return type "Iterator[DummyReply]" of "StreamUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "DummyServiceServicer" [override]
125-
test_negative/negative.py: error: Argument 1 of "StreamUnary" is incompatible with supertype "DummyServiceServicer"; supertype defines the argument type as "_MaybeAsyncIterator[DummyRequest]" [override]
124+
test_negative/negative.py: error: Return type "Iterator[DummyReply]" of "StreamUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer" [override]
125+
test_negative/negative.py: error: Argument 1 of "StreamUnary" is incompatible with supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer"; supertype defines the argument type as "_MaybeAsyncIterator[DummyRequest]" [override]
126126
test_negative/negative.py: note: This violates the Liskov substitution principle
127127
test_negative/negative.py: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
128128
test_negative/negative.py: error: Argument "implicit_singular" to "Editions2024Test" has incompatible type "None"; expected "str" [arg-type]

test_negative/output.expected.3.11

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,22 @@ test_negative/negative.py:204: note: def [_DummyServiceUnaryUnaryType: (Unar
107107
test_negative/negative.py:211: error: "DummyReply" has no attribute "not_exists" [attr-defined]
108108
test_negative/negative.py:212: error: "DummyReply" has no attribute "__iter__" (not iterable) [attr-defined]
109109
test_negative/negative.py:217: error: "DummyReply" has no attribute "not_exists" [attr-defined]
110-
test_negative/negative.py:219: error: "CallIterator[DummyReply]" has no attribute "value" [attr-defined]
110+
test_negative/negative.py:219: error: "_CallIterator[DummyReply]" has no attribute "value" [attr-defined]
111111
test_negative/negative.py:226: error: Argument 1 to "__call__" of "StreamUnaryMultiCallable" has incompatible type "DummyRequest"; expected "Iterator[DummyRequest]" [arg-type]
112112
test_negative/negative.py:228: error: "DummyReply" has no attribute "__iter__" (not iterable) [attr-defined]
113113
test_negative/negative.py:228: error: Argument 1 to "__call__" of "StreamUnaryMultiCallable" has incompatible type "DummyRequest"; expected "Iterator[DummyRequest]" [arg-type]
114114
test_negative/negative.py:231: error: Argument 1 to "__call__" of "StreamStreamMultiCallable" has incompatible type "DummyRequest"; expected "Iterator[DummyRequest]" [arg-type]
115115
test_negative/negative.py:235: error: "DummyReply" has no attribute "not_exists" [attr-defined]
116-
test_negative/negative.py:272: error: Return type "Iterator[DummyReply]" of "UnaryUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "DummyServiceServicer" [override]
117-
test_negative/negative.py:274: error: Argument 1 of "UnaryUnary" is incompatible with supertype "DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
116+
test_negative/negative.py:272: error: Return type "Iterator[DummyReply]" of "UnaryUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer" [override]
117+
test_negative/negative.py:274: error: Argument 1 of "UnaryUnary" is incompatible with supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
118118
test_negative/negative.py:274: note: This violates the Liskov substitution principle
119119
test_negative/negative.py:274: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
120-
test_negative/negative.py:280: error: Return type "DummyReply" of "UnaryStream" incompatible with return type "Iterator[DummyReply] | AsyncIterator[DummyReply]" in supertype "DummyServiceServicer" [override]
121-
test_negative/negative.py:282: error: Argument 1 of "UnaryStream" is incompatible with supertype "DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
120+
test_negative/negative.py:280: error: Return type "DummyReply" of "UnaryStream" incompatible with return type "Iterator[DummyReply] | AsyncIterator[DummyReply]" in supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer" [override]
121+
test_negative/negative.py:282: error: Argument 1 of "UnaryStream" is incompatible with supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer"; supertype defines the argument type as "DummyRequest" [override]
122122
test_negative/negative.py:282: note: This violates the Liskov substitution principle
123123
test_negative/negative.py:282: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
124-
test_negative/negative.py:289: error: Return type "Iterator[DummyReply]" of "StreamUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "DummyServiceServicer" [override]
125-
test_negative/negative.py:291: error: Argument 1 of "StreamUnary" is incompatible with supertype "DummyServiceServicer"; supertype defines the argument type as "_MaybeAsyncIterator[DummyRequest]" [override]
124+
test_negative/negative.py:289: error: Return type "Iterator[DummyReply]" of "StreamUnary" incompatible with return type "DummyReply | Awaitable[DummyReply]" in supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer" [override]
125+
test_negative/negative.py:291: error: Argument 1 of "StreamUnary" is incompatible with supertype "testproto.grpc.dummy_pb2_grpc.DummyServiceServicer"; supertype defines the argument type as "_MaybeAsyncIterator[DummyRequest]" [override]
126126
test_negative/negative.py:291: note: This violates the Liskov substitution principle
127127
test_negative/negative.py:291: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
128128
test_negative/negative.py:331: error: Argument "implicit_singular" to "Editions2024Test" has incompatible type "None"; expected "str" [arg-type]

0 commit comments

Comments
 (0)