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

Question / issue with metaclasses and __init__ #352

Closed
denised opened this issue Feb 16, 2022 · 5 comments
Closed

Question / issue with metaclasses and __init__ #352

denised opened this issue Feb 16, 2022 · 5 comments
Labels

Comments

@denised
Copy link
Contributor

denised commented Feb 16, 2022

Problem Description

In my project, certain classes have a strange result for the class initializer documentation. For example:

image

AdoptionData.__init__ does have its own docstring, and it does not say "call self as function".

The classes that show this behavior all share a common trait: they have the same metaclass, and that metaclass overrides __call__. (The metaclass implements memo-izing/instance caching.)

I am sure that the metaclass is the reason for this behavior, but I haven't quite figured out exactly how this is happening. I can see that the overridden __call__ function might be problematic -- no telling what will happen when you invoke the classname as a function! But I hope there is some way to override this behavior and get it to use my docstring anyway?

Steps to reproduce the behavior:

I'll create a minimal reproduction if needed, but I'm guessing the description is enough?

System Information

Paste the output of "pdoc --version" here: v9.0.1

@denised denised added the bug label Feb 16, 2022
@mhils mhils closed this as completed in 64aab58 Feb 16, 2022
@mhils
Copy link
Member

mhils commented Feb 16, 2022

Thanks, this was useful feedback! We take Metaclass.__call__ into account for special snowflakes like dataclasses and NamedTuples. If the class itself has an __init__ with docstring, we should of course prefer that. Fixed with 64aab58. 😃

@denised
Copy link
Contributor Author

denised commented Feb 16, 2022

Awesome, thank you!

@denised
Copy link
Contributor Author

denised commented Mar 1, 2022

@mhils Can I persuade you to issue a new release with this in it, so my auto-generated documentation will have the right content? 😁

@mhils
Copy link
Member

mhils commented Mar 1, 2022

Sure thing - 10.0.2 just hit PyPI! 😃

@denised
Copy link
Contributor Author

denised commented Mar 1, 2022

Yay it works! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants