autodoc_pydantic
autodoc_pydantic copied to clipboard
Generics not supported?
invalid signature for autopydantic_model ('saf.collect.beacons::PipelineRunContext[BeaconsConfig]')
make: *** [Makefile:20: coverage] Error 2
class BeaconsConfig(CollectConfigBase):
"""
Configuration schema for the beacons collect plugin.
"""
beacons: List[str]
async def collect(*, ctx: PipelineRunContext[BeaconsConfig]) -> AsyncIterator[BeaconCollectedEvent]:
"""
Method called to collect events.
"""
PipelineRunContextConfigType = TypeVar("PipelineRunContextConfigType", bound=NonMutableConfig)
class PipelineRunContext(GenericModel, Generic[PipelineRunContextConfigType]):
"""
Class representing a pipeline run context.
"""
config: PipelineRunContextConfigType
Hi @s0undt3ch,
thanks for raising this issue here. To be honest, I have silently assumed that autodoc_pydantic
handles generic models just as fine as normal pydantic models in the past. Just now I added an example in the documentation showing how generic models are rendered via autodoc_pydantic
. Given the standard example from the pydantic docs, it just works fine.
Nevertheless, I'm pretty sure you've stumbled across an edge case where autodoc_pydantic
might break the building process. However, I need your help to reproduce the error because I'm currently rather new to generics in python:
- Could you please provide a complete self containing example? With the above, I don't know what
NonMutableConfig
is. Moreover, thesaf.collect.beacons
module seems to have a concrete implementation ofPipelineRunContext
withBeaconsConfig
. This is not shown in your code example. - What sphinx/pydantic/autodoc_pydantic versions are you using?
- How do you invoke the building process?
Sure, I'll try to make a self contained version of the error and I'll post it here.
Thank You for your work!