Remove dead code: 64-bit protobuf types never used in 7 years - #9471
Conversation
|
Hey there @OttoWinter, mind taking a look at this pull request as it has been labeled with an integration ( |
There was a problem hiding this comment.
Pull Request Overview
Remove dead protobuf support for 64-bit types and prevent accidental reintroduction by adding validation in the Python API generator and cleaning up the C++ code.
- Eliminate
Proto64Bit, 64-bit encode/decode methods, and size calculations forsint64/fixed64inproto.h. - Introduce
validate_field_typeinapi_protobuf.pyto raise on unsupported 64-bit field types and refactor type info lookups. - Update comments to document the intentional omission of wire type 1 support.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| script/api_protobuf/api_protobuf.py | Added UNSUPPORTED_TYPES map, validate_field_type, and refactored repeated/type lookup to enforce no 64-bit fields. |
| esphome/components/api/proto.h | Removed Proto64Bit, 64-bit encode/decode methods, and sint64 size functions, with comments noting the removal. |
Comments suppressed due to low confidence (2)
script/api_protobuf/api_protobuf.py:321
- No tests exist to verify that validate_field_type raises ValueError for unsupported 64-bit types; consider adding unit tests to cover each unsupported type code to prevent regressions.
def validate_field_type(field_type: int, field_name: str = "") -> None:
script/api_protobuf/api_protobuf.py:342
- Avoid using magic numbers for field labels; use the constant descriptor.FieldDescriptorProto.LABEL_REPEATED instead of literal
3to improve readability and maintainability.
if field.label == 3: # repeated
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #9471 +/- ##
=======================================
Coverage 59.67% 59.67%
=======================================
Files 50 50
Lines 10261 10261
Branches 1379 1379
=======================================
Hits 6123 6123
Misses 3778 3778
Partials 360 360 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What does this implement/fix?
Remove dead code for protobuf wire type 1 (64-bit fixed types) that has never been used in ESPHome's ~7 year history.
The ESPHome API has never used
double,fixed64,sfixed64, orsint64types in its protocol definition. This PR removes all the encoding/decoding infrastructure for these types and adds validation to prevent their accidental introduction.Key points:
Changes:
Proto64Bitclass entirelyencode_fixed64()methodadd_sint64_field()andadd_sint64_field_repeated()functionsdecode_64bit()virtual methodapi_protobuf.pythat raisesValueErrorif these types are usedTypes of changes
Related issue or feature (if applicable): N/A
Pull request in esphome-docs with documentation (if applicable): N/A
Test Environment
Example entry for
config.yaml:Checklist:
tests/folder).If user exposed functionality or configuration variables are added/changed: