Skip to content

Conversation

@aidandj
Copy link
Collaborator

@aidandj aidandj commented Dec 10, 2025

This generates properties instead of attributes for methods, enum values, message fields and adds deprecation decoration if the option is set.

* Express methods as properties, allows for deprecation
* Express enum values as properties, allows for deprecation

Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances deprecation support in the mypy-protobuf plugin by generating properties instead of attributes for deprecated protobuf elements, allowing proper deprecation warnings to be surfaced through type checking.

Key changes:

  • Deprecated message fields, gRPC methods, and enum values are now generated as properties with @deprecated decorators
  • This enables mypy to catch usage of deprecated elements at type-check time
  • Test expectations updated to reflect 9 additional deprecation warnings (from 105 to 114 errors)

Reviewed changes

Copilot reviewed 24 out of 27 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test_negative/output.expected.* Updated expected mypy error counts and line numbers to reflect new deprecation warnings
test_negative/negative.py Added test cases for deprecated fields, methods, and enum values
test/test_generated_mypy.py Updated error count assertion from 90 to 96
test/generated_concrete/testproto/test_pb2.pyi Generated deprecated message fields as properties with deprecation decorators
test/generated_concrete/testproto/grpc/dummy_pb2_grpc.pyi Generated deprecated gRPC methods as properties with deprecation decorators
test/generated_concrete/testproto/grpc/dummy_pb2.pyi Generated deprecated request fields as properties with deprecation decorators
stubtest_allowlist.txt Updated allowlist for properties that don't exist at runtime
run_test.sh Added logging for stubtest execution
proto/testproto/test.proto Added deprecated field definitions for testing
proto/testproto/grpc/dummy.proto Added deprecated method definitions for testing
CHANGELOG.md Documented the new deprecation property generation feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant