Commit f35584a
Add flags to generate only sync or only async stubs (#694)
* Add flags to generate only sync or only async stubs
* Specify type parameters for context in async grpc methods
* Ignore pyright errors in sync/async only stubs
* Update readme with sync_only/async_only option
* Start adding tests
Rename folders
Update pyproject.toml so pyright works on test code for sync/async only
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
* add constructor typing
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
* run black
* isort: skip generated grpc files
* Add init files to generated sync/async
* Add init files to generated sync/async
* Add missing enum import
* Fix linting error and remove generated sync/async only files
- Fix F402 linting error where 'enum' loop variable was shadowing
the enum module import. Renamed loop variable to 'enum_proto'.
- Stage deletion of test/generated_sync_only and test/generated_async_only
directories - these will be regenerated during test runs.
- Update generated_concrete files with latest output.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Update Pyright config to exclude sync/async only test directories
- Remove executionEnvironments entries for test/generated_sync_only and
test/generated_async_only since these directories are being removed
- Exclude test/async_only and test/sync_only directories from Pyright
checking since they depend on generated files that are no longer
committed to git
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Create sync/async only directories before generating files
Add mkdir -p commands to create test/generated_sync_only and
test/generated_async_only directories before protoc tries to write
files into them. These directories are no longer committed to git
and need to be created during test runs.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Add --report-deprecated-as-note to sync/async only mypy checks
The sync_only and async_only mypy checks were missing the
--report-deprecated-as-note flag, causing deprecation warnings to be
treated as errors. This flag is already used for the concrete module
checks and should also be used for these tests.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Fix async_only test to use DummyServiceAsyncStub
When generating with the only_async flag, the stub class is named
DummyServiceAsyncStub, not DummyServiceStub. Update the test to use
the correct async stub class name.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Address review comments: error handling and simplify server type logic
- Add error checking when both only_sync and only_async options are specified
- Simplify make_server_type() logic using direct comparisons instead of if/elif chain
- Check in generated sync_only and async_only test files so CI can run tests
- Add __init__.py files to generated sync/async directories for proper package structure
Typed constructors were already present in the generated code.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Improve tests and add pyright support for sync/async only
- Add comprehensive tests for sync_only and async_only that actually run
servers and clients, equivalent to test_grpc_usage.py and test_grpc_async_usage.py
- Restore pyright executionEnvironments for generated_sync_only and generated_async_only
- Add executionEnvironments for test/async_only and test/sync_only with proper extraPaths
- Clean generated_sync_only and generated_async_only directories in test script
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Fix async_only test context types to match generated stubs
Update ServicerContext type parameters to match the exact types in the
generated async_only stubs. The context type parameters should match
the method return types (Awaitable or AsyncIterator).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Fix async_only test to use DummyServiceStub at runtime
The generated _pb2_grpc.py file only exports DummyServiceStub, while the
.pyi file has DummyServiceAsyncStub as a type alias. This matches the
pattern in test_grpc_async_usage.py.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Add type alias for Stub in async_only mode
In async_only mode, the .pyi file now defines both DummyServiceAsyncStub
(the actual class) and DummyServiceStub (a type alias). This matches the
runtime behavior where grpc_tools.protoc generates DummyServiceStub in
the .py file.
Fixes type checking errors where mypy couldn't find DummyServiceStub.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Use Stub naming in async_only mode (not AsyncStub)
In async_only mode, generate class DummyServiceStub instead of
DummyServiceAsyncStub with a type alias. Since there's only one stub
type, it should use the standard Stub naming that matches the runtime
.py file generated by grpc_tools.protoc.
This addresses review feedback from @aidandj.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Update changelog
---------
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
Co-authored-by: Aidan Jensen <aidandj.github@gmail.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 38362fb commit f35584a
File tree
87 files changed
+9467
-80
lines changed- mypy_protobuf
- test
- async_only
- generated_async_only/testproto
- Capitalized
- dot
- com
- grpc
- inner
- nested
- generated_sync_only/testproto
- Capitalized
- dot
- com
- grpc
- inner
- nested
- sync_only
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
87 files changed
+9467
-80
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
351 | 366 | | |
352 | 367 | | |
353 | 368 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
42 | 44 | | |
| 45 | + | |
| 46 | + | |
43 | 47 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
| |||
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
138 | 147 | | |
139 | 148 | | |
140 | 149 | | |
| |||
153 | 162 | | |
154 | 163 | | |
155 | 164 | | |
| 165 | + | |
| 166 | + | |
156 | 167 | | |
157 | 168 | | |
158 | 169 | | |
| |||
162 | 173 | | |
163 | 174 | | |
164 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
165 | 184 | | |
166 | 185 | | |
167 | 186 | | |
| |||
210 | 229 | | |
211 | 230 | | |
212 | 231 | | |
213 | | - | |
| 232 | + | |
214 | 233 | | |
215 | 234 | | |
216 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
Lines changed: 71 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
Whitespace-only changes.
0 commit comments