-
Notifications
You must be signed in to change notification settings - Fork 84
DRAFT Add flags to generate only sync or only async stubs #694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
d946d68
9727cbf
52e18dd
ddd9a2f
28d2401
3298f4b
cb32bd6
c497b7d
82e6e75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,6 +135,11 @@ | |
| find proto -name "*.proto" -print0 | xargs -0 "$PROTOC" "${PROTOC_ARGS[@]}" --mypy_out=generate_concrete_servicer_stubs:test/generated-concrete | ||
| find proto/testproto/grpc -name "*.proto" -print0 | xargs -0 "$PROTOC" "${PROTOC_ARGS[@]}" --mypy_grpc_out=generate_concrete_servicer_stubs:test/generated-concrete | ||
|
|
||
| # Generate with sync_only stubs for testing | ||
| find proto/testproto/grpc -name "*.proto" -print0 | xargs -0 "$PROTOC" "${PROTOC_ARGS[@]}" --mypy_grpc_out=only_sync:test/generated-sync-only | ||
|
|
||
| # Generate with async_only stubs for testing | ||
| find proto/testproto/grpc -name "*.proto" -print0 | xargs -0 "$PROTOC" "${PROTOC_ARGS[@]}" --mypy_grpc_out=only_async:test/generated-async-only | ||
|
||
|
|
||
| if [[ -n $VALIDATE ]] && ! diff <(echo "$SHA_BEFORE") <(find test/generated -name "*.pyi" -print0 | xargs -0 sha1sum); then | ||
| echo -e "${RED}Some .pyi files did not match. Please commit those files${NC}" | ||
|
|
@@ -161,6 +166,14 @@ | |
| CONCRETE_MODULES=( -m test.test_concrete ) | ||
| MYPYPATH=$MYPYPATH:test/generated-concrete mypy ${CUSTOM_TYPESHED_DIR_ARG:+"$CUSTOM_TYPESHED_DIR_ARG"} --python-executable="$UNIT_TESTS_VENV"/bin/python --python-version="$PY_VER_MYPY_TARGET" "${CONCRETE_MODULES[@]}" | ||
|
|
||
| # Run sync_only mypy | ||
| SYNC_ONLY_MODULES=( -m test.test_sync_only ) | ||
| MYPYPATH=$MYPYPATH:test/generated-sync-only mypy ${CUSTOM_TYPESHED_DIR_ARG:+"$CUSTOM_TYPESHED_DIR_ARG"} --python-executable="$UNIT_TESTS_VENV"/bin/python --python-version="$PY_VER_MYPY_TARGET" "${SYNC_ONLY_MODULES[@]}" | ||
|
|
||
| # Run async_only mypy | ||
| ASYNC_ONLY_MODULES=( -m test.test_async_only ) | ||
| MYPYPATH=$MYPYPATH:test/generated-async-only mypy ${CUSTOM_TYPESHED_DIR_ARG:+"$CUSTOM_TYPESHED_DIR_ARG"} --python-executable="$UNIT_TESTS_VENV"/bin/python --python-version="$PY_VER_MYPY_TARGET" "${ASYNC_ONLY_MODULES[@]}" | ||
|
|
||
| export MYPYPATH=$MYPYPATH:test/generated | ||
|
|
||
| # Run mypy | ||
|
|
@@ -202,21 +215,21 @@ | |
| cp "$MYPY_OUTPUT/mypy_output.omit_linenos" "test_negative/output.expected.$PY_VER_MYPY_TARGET.omit_linenos" | ||
|
|
||
| # Record error instead of echoing and exiting | ||
| ERRORS+=("test_negative/output.expected.$PY_VER_MYPY_TARGET didnt match. Copying over for you.") | ||
|
Check warning on line 218 in run_test.sh
|
||
| fi | ||
| ) | ||
|
|
||
| ( | ||
| # Run unit tests. | ||
| source "$UNIT_TESTS_VENV"/bin/activate | ||
| PYTHONPATH=test/generated py.test --ignore=test/generated -v | ||
| PYTHONPATH=test/generated py.test --ignore=test/generated --ignore=test/generated-sync-only --ignore=test/generated-async-only -v | ||
| ) | ||
| done | ||
|
|
||
| # Report all errors at the end | ||
| if [ ${#ERRORS[@]} -gt 0 ]; then | ||
|
Check warning on line 230 in run_test.sh
|
||
| echo -e "\n${RED}===============================================${NC}" | ||
| for error in "${ERRORS[@]}"; do | ||
|
Check warning on line 232 in run_test.sh
|
||
| echo -e "${RED}$error${NC}" | ||
| done | ||
| echo -e "${RED}Now rerun${NC}" | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| """ | ||
| @generated by mypy-protobuf. Do not edit manually! | ||
| isort:skip_file | ||
| """ | ||
|
|
||
| import builtins | ||
| import google.protobuf.descriptor | ||
| import google.protobuf.message | ||
| import sys | ||
| import typing | ||
|
|
||
| if sys.version_info >= (3, 10): | ||
| import typing as typing_extensions | ||
| else: | ||
| import typing_extensions | ||
|
|
||
| DESCRIPTOR: google.protobuf.descriptor.FileDescriptor | ||
|
|
||
| @typing.final | ||
| class lower(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| A_FIELD_NUMBER: builtins.int | ||
| a: builtins.int | ||
| def __init__( | ||
| self, | ||
| *, | ||
| a: builtins.int = ..., | ||
| ) -> None: ... | ||
| def ClearField(self, field_name: typing.Literal["a", b"a"]) -> None: ... | ||
|
|
||
| Global___lower: typing_extensions.TypeAlias = lower | ||
|
|
||
| @typing.final | ||
| class Upper(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| LOWER_FIELD_NUMBER: builtins.int | ||
| @property | ||
| def Lower(self) -> Global___lower: ... | ||
| def __init__( | ||
| self, | ||
| *, | ||
| Lower: Global___lower | None = ..., | ||
| ) -> None: ... | ||
| def HasField(self, field_name: typing.Literal["Lower", b"Lower"]) -> builtins.bool: ... | ||
| def ClearField(self, field_name: typing.Literal["Lower", b"Lower"]) -> None: ... | ||
|
|
||
| Global___Upper: typing_extensions.TypeAlias = Upper | ||
|
|
||
| @typing.final | ||
| class lower2(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| UPPER_FIELD_NUMBER: builtins.int | ||
| @property | ||
| def upper(self) -> Global___Upper: ... | ||
| def __init__( | ||
| self, | ||
| *, | ||
| upper: Global___Upper | None = ..., | ||
| ) -> None: ... | ||
| def HasField(self, field_name: typing.Literal["upper", b"upper"]) -> builtins.bool: ... | ||
| def ClearField(self, field_name: typing.Literal["upper", b"upper"]) -> None: ... | ||
|
|
||
| Global___lower2: typing_extensions.TypeAlias = lower2 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| """ | ||
| @generated by mypy-protobuf. Do not edit manually! | ||
| isort:skip_file | ||
| """ | ||
|
|
||
| import builtins | ||
| import google.protobuf.descriptor | ||
| import google.protobuf.message | ||
| import sys | ||
| import typing | ||
|
|
||
| if sys.version_info >= (3, 10): | ||
| import typing as typing_extensions | ||
| else: | ||
| import typing_extensions | ||
|
|
||
| DESCRIPTOR: google.protobuf.descriptor.FileDescriptor | ||
|
|
||
| @typing.final | ||
| class Test(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| A_FIELD_NUMBER: builtins.int | ||
| B_FIELD_NUMBER: builtins.int | ||
| C_FIELD_NUMBER: builtins.int | ||
| D_FIELD_NUMBER: builtins.int | ||
| E_FIELD_NUMBER: builtins.int | ||
| F_FIELD_NUMBER: builtins.int | ||
| G_FIELD_NUMBER: builtins.int | ||
| H_FIELD_NUMBER: builtins.int | ||
| I_FIELD_NUMBER: builtins.int | ||
| J_FIELD_NUMBER: builtins.int | ||
| K_FIELD_NUMBER: builtins.int | ||
| a: builtins.str | ||
| """Ending with " """ | ||
| b: builtins.str | ||
| """Ending with "" """ | ||
| c: builtins.str | ||
| """Ending with \"\"\" """ | ||
| d: builtins.str | ||
| """Ending with \\ """ | ||
| e: builtins.str | ||
| """Containing bad escape: \\x""" | ||
| f: builtins.str | ||
| """Containing \"\"\"" quadruple""" | ||
| g: builtins.str | ||
| """Containing \"\"\""" quintuple""" | ||
| h: builtins.str | ||
| """Containing \"\"\"\"\"\" sextuple""" | ||
| i: builtins.str | ||
| """\"\"\" Multiple \"\"\" triples \"\"\" """ | ||
| j: builtins.str | ||
| """"quotes" can be a problem in comments. | ||
| \"\"\"Triple quotes\"\"\" just as well | ||
| """ | ||
| k: builtins.str | ||
| """\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" | ||
| " " | ||
| " Super Duper comments with surrounding edges! " | ||
| " " | ||
| " Pay attention to me!!!! " | ||
| " " | ||
| \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" | ||
| """ | ||
| def __init__( | ||
| self, | ||
| *, | ||
| a: builtins.str = ..., | ||
| b: builtins.str = ..., | ||
| c: builtins.str = ..., | ||
| d: builtins.str = ..., | ||
| e: builtins.str = ..., | ||
| f: builtins.str = ..., | ||
| g: builtins.str = ..., | ||
| h: builtins.str = ..., | ||
| i: builtins.str = ..., | ||
| j: builtins.str = ..., | ||
| k: builtins.str = ..., | ||
| ) -> None: ... | ||
| def ClearField(self, field_name: typing.Literal["a", b"a", "b", b"b", "c", b"c", "d", b"d", "e", b"e", "f", b"f", "g", b"g", "h", b"h", "i", b"i", "j", b"j", "k", b"k"]) -> None: ... | ||
|
|
||
| Global___Test: typing_extensions.TypeAlias = Test |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| """ | ||
| @generated by mypy-protobuf. Do not edit manually! | ||
| isort:skip_file | ||
| """ | ||
|
|
||
| import builtins | ||
| import google.protobuf.descriptor | ||
| import google.protobuf.message | ||
| import sys | ||
| import typing | ||
|
|
||
| if sys.version_info >= (3, 10): | ||
| import typing as typing_extensions | ||
| else: | ||
| import typing_extensions | ||
|
|
||
| DESCRIPTOR: google.protobuf.descriptor.FileDescriptor | ||
|
|
||
| @typing.final | ||
| class TestMessage(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| FOO_FIELD_NUMBER: builtins.int | ||
| foo: builtins.str | ||
| def __init__( | ||
| self, | ||
| *, | ||
| foo: builtins.str = ..., | ||
| ) -> None: ... | ||
| def ClearField(self, field_name: typing.Literal["foo", b"foo"]) -> None: ... | ||
|
|
||
| Global___TestMessage: typing_extensions.TypeAlias = TestMessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generated_sync_only