python icon indicating copy to clipboard operation
python copied to clipboard

Force inspection

Open mdelmans opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. I have some dynamically-generated classes that need to be inspected rather than visited and I can't find an option to force inspection.

Describe the solution you'd like Would be nice to have a force_inspection option.

Describe alternatives you've considered I tried importing classes manually inside extension but extensions do not provide access to griffe inspector to fetch dynamic class attributes.

Additional context I'm dealing with for Pydantic BaseModel classes and I managed to inject field info through an extension and override the template to render things the way I want. Some of my models are dynamically-generated and their attributes are not picked up.

Inside my extension, I import the class, inspect its fields and add an extra key to each attribute containing field info. But for the dynamically-generated models I have no attributes to inject field info to.

Hope it makes sense.

mdelmans avatar Aug 01 '23 12:08 mdelmans

Thanks for the request, I think it makes sense :slightly_smiling_face: You can try and send a PR to the Griffe repo to add such an option if you want.

You might also be interested in the extension we provide for Pydantic: https://mkdocstrings.github.io/griffe-pydantic/. Note that it's only available to sponsors. It's probably possible to improve it to support your use-case.

pawamoy avatar Aug 02 '23 14:08 pawamoy

May I ask why you closed your request @mdelmans :slightly_smiling_face:?

pawamoy avatar Aug 25 '23 10:08 pawamoy

I'm still interested so I reopened, hope you don't mind.

pawamoy avatar Aug 30 '23 17:08 pawamoy

@pawamoy sorry, didn't mean to. Happy if it stays open.

mdelmans avatar Sep 04 '23 19:09 mdelmans