Describe the bug
I use mkdocstrings
and have a Django project where I started using factory-boy
. Once I added a factory class (sub-class of factory.django.DjangoModelFactory
) the following error occurs:
Traceback (most recent call last):
File "<snip>/.venv/lib/python3.10/site-packages/pytkdocs/cli.py", line 205, in main
output = json.dumps(process_json(line))
File "<snip>/.venv/lib/python3.10/site-packages/pytkdocs/cli.py", line 114, in process_json
return process_config(json.loads(json_input))
File "<snip>/.venv/lib/python3.10/site-packages/pytkdocs/cli.py", line 91, in process_config
obj = loader.get_object_documentation(path, members)
File "<snip>/.venv/lib/python3.10/site-packages/pytkdocs/loader.py", line 358, in get_object_documentation
root_object = self.get_module_documentation(leaf, members)
File "<snip>/.venv/lib/python3.10/site-packages/pytkdocs/loader.py", line 426, in get_module_documentation
root_object.add_child(self.get_class_documentation(child_node))
File "<snip>/.venv/lib/python3.10/site-packages/pytkdocs/loader.py", line 542, in get_class_documentation
if self.detect_field_model(attr_name, direct_members, all_members):
File "<snip>/.venv/lib/python3.10/site-packages/pytkdocs/loader.py", line 577, in detect_field_model
if remainder and not attrgetter(remainder)(all_members[first_order_attr_name]):
AttributeError: 'DjangoOptions' object has no attribute 'get_fields'
To Reproduce
Creating a factory class for Django's user model should be sufficient:
from django.contrib.auth import get_user_model
from factory.django import DjangoModelFactory
User = get_user_model()
class UserFactory(DjangoModelFactory):
class Meta:
model = User
Expected behavior
Not sure if it is a bug in retrieving information from the class. I think simply ignoring should be sufficient.
System (please complete the following information):
pytkdocs
version: 0.16.0Additional context
I was able to workaround this problem by ensuring that the attr exists:
if not hasattr(all_members[first_order_attr_name], remainder):
return False
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too