Modernize codebase for Python 3.13+#13
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR modernizes the Bakelite codebase by migrating to Python 3.10+ syntax, updating type annotations to use builtin generics and union operators, introducing new runtime descriptor types, refactoring serialization decorators to use protocols instead of JSON strings, and adding comprehensive test coverage. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
51ddf34 to
fee9b06
Compare
Separate type descriptors (ProtoType, ProtoStruct, etc.) into bakelite/proto/types.py for use in generated code without pulling in external dependencies like dataclasses_json.
- Update type hints to modern syntax (X | None, list[X]) - Apply Ruff formatting and linting fixes - Rename arraySize to array_size for snake_case consistency - Fix parser bug with bytes[] (variable-length) parsing - Add comprehensive test coverage (CLI, parser, CRC) - Use Protocol class for type checking instead of type: ignore
- Carry forward review fixes (size=None, conftest plugin name, typos) - Modernize python.py types (List → list, Optional → |, arraySize → array_size) - Add runtime_import parameter to render() for generated code compatibility - Fix struct/enum decorators to accept JSON strings from generated code - Skip runtime CLI tests (feature added in later PR) - Refactor cli.py gen command to avoid function pointer type mismatch
fee9b06 to
34a256e
Compare
Summary
bakelite/proto/types.py) for use in generated code without heavy dependenciesX | None,list[X])arraySizetoarray_sizefor snake_case consistencybytes[](variable-length) parsingProtocolclass for type checking instead oftype: ignoreTest plan
pixi run pytestpasses (116 tests)pixi run ruff checkcleanpixi run mypycleanSummary by CodeRabbit
Release Notes
Bug Fixes
Tests
Refactor
list[...]instead oftyping.List[...]).PackableProtocol,EnumProtocol) for improved type safety.