-
Notifications
You must be signed in to change notification settings - Fork 83
Add additional deprecation support #713
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?
Conversation
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.
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
@deprecateddecorators - 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.
98e7152 to
4d7046f
Compare
nipunn1313
left a comment
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.
nice feature!
nipunn1313
left a comment
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.
I suppose - this is the kind of feature that might break on some corner case that we didn't anticipate. If there are any large .proto codebases out in the wild we could try it on, that could help give some confidence
I asked for some input in issues and haven't heard, I'll do some more looking tonight. I added all the Google protobuf protos as a test, but they don't use my deprecation. At first I changed them all to properties, but to minimize the blast radius I did it only for deprecated objects. I know of a few large protobuf projects, but finding one that uses mypy protobuf, is fully static typed has been more challenging. |
git-subtree-dir: third_party/googleapis git-subtree-split: 6d6acd2e993c45a7a45fc6374d6c2fc987af1f77
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
* 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>
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
4d7046f to
4b0decf
Compare
This generates properties instead of attributes for methods, enum values, message fields and adds deprecation decoration if the option is set.