Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics not supported? #115

Open
s0undt3ch opened this issue Apr 15, 2022 · 2 comments
Open

Generics not supported? #115

s0undt3ch opened this issue Apr 15, 2022 · 2 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@s0undt3ch
Copy link

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
@mansenfranzen
Copy link
Owner

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, the saf.collect.beacons module seems to have a concrete implementation of PipelineRunContext with BeaconsConfig. This is not shown in your code example.
  • What sphinx/pydantic/autodoc_pydantic versions are you using?
  • How do you invoke the building process?

@mansenfranzen mansenfranzen self-assigned this Apr 15, 2022
@mansenfranzen mansenfranzen added bug Something isn't working documentation Improvements or additions to documentation labels Apr 15, 2022
@s0undt3ch
Copy link
Author

s0undt3ch commented Apr 15, 2022

Sure, I'll try to make a self contained version of the error and I'll post it here.

Thank You for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants