Enum resolvers: Add status enum for each entity type#962
Conversation
|
Instead of having a separate resolver for every entity, couldn't we just use params? (add |
That would be better, BUT how would you then use it in |
|
You mean in settings? This should work: class MySettings(BaseSettingsModel):
folder_status: Annotated[str, SettingsField(enum_resolver=lambda: EnumRegistry.resolve("statuses", entity_type="folder)]
|
So what is |
|
The point is, that resolvers can have multiple parameter. and you'd need to write a resolver for every combination :) the resolver already accepts project_name (but it is auto-populated in the case of settings). Also, having a central registry means that we can (well - we could, if we had time) export documentation: list all resolvers and accepted parameters. |
|
Ok, still, same question as above, what is |
|
Would the current approach work, added entity type param and also added |
kalisp
left a comment
There was a problem hiding this comment.
LGTM but probably @martastain should approve too
PR Checklist
Added statuses enum resolver for each entity type there is.
Description of changes
Class
StatusesEnumResolvernow has definedentity_typesto define set of available entity types for which to return statuses. The entity types enum is filtering them by the value and also create new items based on it. Then were added separate classes for each entity type.Technical details
I first added
entity_typeas a string and then changed it toset[str], not sure if there might be usecase in future to be able to show statuses for folder and task at the same time? If not it should be easy to revertentity_typestoentity_type.Additional context
Currently the
StatusesEnumResolverreally can't be used in production as the usage is always scoped to a certain entity type.