cappa icon indicating copy to clipboard operation
cappa copied to clipboard

Avoid stub class construction

Open DanCardin opened this issue 4 months ago • 0 comments

Right now "functional" declaration internally creates stub dataclasses to use downstream to contruct Command instances, because the way invoked subcommands work internally traverses the output shape to find subcommand instances.

Each of the below steps ought to be able to correspond to a standalone PR that doesn't break anything in order to remove this weird internal traversal and construction, greatly simplifying function handling.

  • [ ] inside map_result, collect all instantiated subcommand instances in a collection in during the recursive production of the output structure. Pass this structure to invoke machinery, so it doesn't need to traverse real-world attributes to resolve implicit deps
  • [ ] combine the two divergent Command.collect codepaths. pre-existence of arguments shouldn't break anything(?)
  • [ ] unclear whether we need Field.annotation, if CallableView is handling production of type_view generally, remove this?
  • [ ] alter class_inspect to introspect callables directly and return fields without constructing a fake class

All of the above ought to make #168 or other click-ish APIs simpler.

DanCardin avatar Oct 29 '25 13:10 DanCardin