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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ __pycache__/
*.pyc
/test/generated/**/*.py
!/test/generated/**/__init__.py
/test/generated-concrete/**/*.py
!/test/generated-concrete/**/__init__.py
/test/generated_concrete/**/*.py
!/test/generated_concrete/**/__init__.py
.pytest_cache
/build/
/dist/
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ exclude = [
executionEnvironments = [
# Due to how upb is typed, we need to disable incompatible variable override checks
{ root = "test/generated", extraPaths = ["./"], reportIncompatibleVariableOverride = "none" },
{ root = "test/generated-concrete", extraPaths = ["./"], reportIncompatibleVariableOverride = "none" },
{ root = "test/generated_concrete", extraPaths = ["./"], reportIncompatibleVariableOverride = "none" },
{ root = "mypy_protobuf/extensions_pb2.pyi", reportIncompatibleVariableOverride = "none" },
]
6 changes: 3 additions & 3 deletions run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
find proto/testproto/grpc -name "*.proto" -print0 | xargs -0 "$PROTOC" "${PROTOC_ARGS[@]}" --mypy_grpc_out=test/generated

# Generate with concrete service stubs for testing
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
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


if [[ -n $VALIDATE ]] && ! diff <(echo "$SHA_BEFORE") <(find test/generated -name "*.pyi" -print0 | xargs -0 sha1sum); then
Expand All @@ -159,7 +159,7 @@
source "$MYPY_VENV"/bin/activate
# Run concrete mypy
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[@]}"
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[@]}"

export MYPYPATH=$MYPYPATH:test/generated

Expand Down Expand Up @@ -202,7 +202,7 @@
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 205 in run_test.sh

View workflow job for this annotation

GitHub Actions / Linting

[shellcheck] reported by reviewdog 🐶 Modification of ERRORS is local (to subshell caused by (..) group). Raw Output: ./run_test.sh:205:13: info: Modification of ERRORS is local (to subshell caused by (..) group). (ShellCheck.SC2030)
fi
)

Expand All @@ -214,9 +214,9 @@
done

# Report all errors at the end
if [ ${#ERRORS[@]} -gt 0 ]; then

Check warning on line 217 in run_test.sh

View workflow job for this annotation

GitHub Actions / Linting

[shellcheck] reported by reviewdog 🐶 ERRORS was modified in a subshell. That change might be lost. Raw Output: ./run_test.sh:217:6: info: ERRORS was modified in a subshell. That change might be lost. (ShellCheck.SC2031)
echo -e "\n${RED}===============================================${NC}"
for error in "${ERRORS[@]}"; do

Check warning on line 219 in run_test.sh

View workflow job for this annotation

GitHub Actions / Linting

[shellcheck] reported by reviewdog 🐶 ERRORS was modified in a subshell. That change might be lost. Raw Output: ./run_test.sh:219:19: info: ERRORS was modified in a subshell. That change might be lost. (ShellCheck.SC2031)
echo -e "${RED}$error${NC}"
done
echo -e "${RED}Now rerun${NC}"
Expand Down
68 changes: 68 additions & 0 deletions test/generated_concrete/testproto/edition2024_pb2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
Edition version of proto2 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 Editions2024SubMessage(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

THING_FIELD_NUMBER: builtins.int
thing: builtins.str
def __init__(
self,
*,
thing: builtins.str | None = ...,
) -> None: ...
def HasField(self, field_name: typing.Literal["thing", b"thing"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["thing", b"thing"]) -> None: ...

Global___Editions2024SubMessage: typing_extensions.TypeAlias = Editions2024SubMessage

@typing.final
class Editions2024Test(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

LEGACY_FIELD_NUMBER: builtins.int
EXPLICIT_SINGULAR_FIELD_NUMBER: builtins.int
MESSAGE_FIELD_FIELD_NUMBER: builtins.int
IMPLICIT_SINGULAR_FIELD_NUMBER: builtins.int
DEFAULT_SINGULAR_FIELD_NUMBER: builtins.int
legacy: builtins.str
"""Expect to be always set"""
explicit_singular: builtins.str
"""Expect HasField generated"""
implicit_singular: builtins.str
"""Expect implicit field presence, no HasField generated"""
default_singular: builtins.str
"""Not set, should default to EXPLICIT"""
@property
def message_field(self) -> Global___Editions2024SubMessage:
"""Expect HasField generated?"""

def __init__(
self,
*,
legacy: builtins.str | None = ...,
explicit_singular: builtins.str | None = ...,
message_field: Global___Editions2024SubMessage | None = ...,
implicit_singular: builtins.str = ...,
default_singular: builtins.str | None = ...,
) -> None: ...
def HasField(self, field_name: typing.Literal["default_singular", b"default_singular", "explicit_singular", b"explicit_singular", "legacy", b"legacy", "message_field", b"message_field"]) -> builtins.bool: ...
def ClearField(self, field_name: typing.Literal["default_singular", b"default_singular", "explicit_singular", b"explicit_singular", "implicit_singular", b"implicit_singular", "legacy", b"legacy", "message_field", b"message_field"]) -> None: ...

Global___Editions2024Test: typing_extensions.TypeAlias = Editions2024Test
Loading