Question / issue with metaclasses and __init__
See original GitHub issueProblem Description
In my project, certain classes have a strange result for the class initializer documentation. For example:
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
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
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 https://github.com/mitmproxy/pdoc/commit/64aab58976320e5941f4dc25f105ce8ffca97fe6. 😃Yay it works! Thank you