Skip to content

Refactor cflib2 package: split flat re-exports into dedicated submodules#8

Merged
gemenerik merged 1 commit intomainfrom
rik/reorg
Mar 19, 2026
Merged

Refactor cflib2 package: split flat re-exports into dedicated submodules#8
gemenerik merged 1 commit intomainfrom
rik/reorg

Conversation

@gemenerik
Copy link
Member

Move exception types, TOC cache classes, and subsystem types out of cflib2/init.py into dedicated submodules (cflib2.error, cflib2.toc_cache, cflib2.commander, cflib2.log, cflib2.param, cflib2.memory, cflib2.localization, cflib2.platform, cflib2.console, cflib2.high_level_commander). The top-level package now only exports Crazyflie and LinkContext. Relocate trajectory data types (Poly, Poly4D, CompressedStart, CompressedSegment) to memory.py. Update example imports accordingly.

Move exception types, TOC cache classes, and subsystem types out of cflib2/__init__.py into dedicated submodules (cflib2.error, cflib2.toc_cache, cflib2.commander, cflib2.log, cflib2.param, cflib2.memory, cflib2.localization, cflib2.platform, cflib2.console, cflib2.high_level_commander). The top-level package now only exports Crazyflie and LinkContext. Relocate trajectory data types (Poly, Poly4D, CompressedStart, CompressedSegment) to memory.py. Update example imports accordingly.
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 reorganizes the Python-facing API surface of cflib2 by moving most Rust-exposed types into dedicated subsystem modules (e.g., cflib2.error, cflib2.toc_cache, cflib2.memory) and keeping the package root focused on core entry points (Crazyflie, LinkContext). Examples and tests are updated to use the new import locations.

Changes:

  • Reduce cflib2 top-level re-exports to just Crazyflie and LinkContext.
  • Add lightweight subsystem modules that re-export Rust types and define clear __all__ sets (error, log, param, memory, etc.).
  • Update examples/tests to import types from the new subsystem modules.

Reviewed changes

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

Show a summary per file
File Description
tests/test_exceptions.py Switch exception hierarchy test to read exception types from cflib2.error instead of the root package.
examples/trajectory.py Fix trajectory primitive imports by using cflib2.memory for Poly/Poly4D.
examples/toc_cache.py Update cache class imports to come from cflib2.toc_cache.
examples/swarm.py Update cache class imports to come from cflib2.toc_cache.
cflib2/init.py Narrow root exports to Crazyflie and LinkContext only.
cflib2/error.py New exception-focused module re-exporting Rust exception types.
cflib2/toc_cache.py New module re-exporting TOC cache types from Rust.
cflib2/memory.py New module re-exporting memory/trajectory-related data types from Rust.
cflib2/commander.py Repurpose module to export the Commander subsystem wrapper (instead of trajectory primitives).
cflib2/high_level_commander.py New module re-exporting the HighLevelCommander subsystem wrapper.
cflib2/console.py New module re-exporting the Console subsystem wrapper.
cflib2/log.py New module re-exporting log subsystem types.
cflib2/param.py New module re-exporting parameter subsystem types.
cflib2/platform.py New module re-exporting platform subsystem types.
cflib2/localization.py New module re-exporting localization subsystem types.

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

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Member

@ataffanel ataffanel left a comment

Choose a reason for hiding this comment

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

Looks good!

@gemenerik gemenerik merged commit c28f957 into main Mar 19, 2026
5 checks passed
@gemenerik gemenerik deleted the rik/reorg branch March 19, 2026 10:38
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.

Restructure Memory API with sub-objects for trajectory (and future memory types)

3 participants