Skip to content

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

Merged
tlambert03 merged 9 commits intopyapp-kit:mainfrom
tlambert03:more-registry-control
May 8, 2024
Merged

feat: give registries more control over registration of actions#194
tlambert03 merged 9 commits intopyapp-kit:mainfrom
tlambert03:more-registry-control

Conversation

@tlambert03
Copy link
Copy Markdown
Member

@tlambert03 tlambert03 commented May 6, 2024

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
Copy link
Copy Markdown

codecov bot commented May 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tlambert03
Copy link
Copy Markdown
Member Author

@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)

@tlambert03 tlambert03 merged commit e92923c into pyapp-kit:main May 8, 2024
@tlambert03 tlambert03 deleted the more-registry-control branch May 8, 2024 13:28
@tlambert03 tlambert03 added the enhancement New feature or request label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

1 participant