pyapp-kit / app-model

Generic application schema implemented in python.
https://app-model.rtfd.io
BSD 3-Clause "New" or "Revised" License
18 stars 12 forks source link

feat: give registries more control over registration of actions #194

Closed tlambert03 closed 5 months ago

tlambert03 commented 5 months ago

This PR moves some of the logic in the register_action function into methods on the registries themselves. This will make it easier for custom subclasses of registries to control exactly how they register actions.
It has some relatively inconsequential other stuff, like making RegisteredCommand immutable and public

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (65b221e) to head (74a14e2).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #194 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 31 31 Lines 1785 1811 +26 ========================================= + Hits 1785 1811 +26 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tlambert03 commented 5 months ago

@Czaki, with this PR, you should be able to use your own Action subclass.

  1. do whatever you want to subclass and extend Action
  2. do whatever you want to subclass and extend CommandRegistry (note that there is now a CommandRegistry.register_action method that you can extend/override)
  3. pass your CommandRegistry subclass type here when you initialize your app (e.g. super().__init__(app_name, raise_synchronous_exceptions=True, commands_reg_class=NapariCommandRegistry)