Improve how to get different types of Dispatch.target
#139
Labels
part:client
Affects the client code
priority:high
Address this as soon as possible
scope:breaking-change
Breaking change, users will need to update their code
type:enhancement
New feature or enhancement visitble to users
What's needed?
It is difficult to use the current targets, defined as
TargetComponents = list[int] | list[ComponentCategory]
, because thematch
statement (andisinstance()
can't deal with containers, so we can check that something is alist
but not that is alist[int]
. We had issues in the past getting this right and we still do.Proposed solution
Use wrapper classes, and then the match syntax should work (I think, untested):
While we are it, maybe we can even change this to use
frozenset
instead oflist
to make it clear there should be no duplicates.Use cases
No response
Alternatives and workarounds
Another option could be to make
TargetComponents
a class and have methods to check which (ids or categories) are really present, but I think it will be more implementation boileplate, and a unsafer usage (as it would be hard to get exhaustion checks in case more ways to specify targets are added in the future).Additional context
No response
The text was updated successfully, but these errors were encountered: