Re: [Django] #35179: Admindocs treats model some model methods containing positional-only arguments or keyword-only arguments as attributes

2 views
Skip to first unread message

Django

unread,
Feb 9, 2024, 11:06:03 AMFeb 9
to django-...@googlegroups.com
#35179: Admindocs treats model some model methods containing positional-only
arguments or keyword-only arguments as attributes
-----------------------------------+--------------------------------------
Reporter: David Sanders | Owner: nobody
Type: Bug | Status: new
Component: contrib.admindocs | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by David Sanders):

* Attachment "admindocs.png" added.

Screenshot of admindocs treating some methods as attributes
--
Ticket URL: <https://code.djangoproject.com/ticket/35179>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 9, 2024, 1:13:31 PMFeb 9
to django-...@googlegroups.com
#35179: Admindocs treats model some model methods containing positional-only
arguments or keyword-only arguments as attributes
-----------------------------------+------------------------------------
Reporter: David Sanders | Owner: nobody
Type: Bug | Status: new
Component: contrib.admindocs | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Natalia Bidart):

* version: 5.0 => dev
* stage: Unreviewed => Accepted

Comment:

After some investigation, this definitely seems like a valid issue. I did
some initial debugging, and both methods are being detected as fields
because the guard (in django/contrib/admindocs/views.py:ModelDetailView):

{{{#!python
elif (
method_has_no_args(func)
and not func_accepts_kwargs(func)
and not func_accepts_var_args(func)
):
fields.append(
{
"name": func_name,
"data_type": get_return_data_type(func_name),
"verbose": verbose or "",
}
)
}}}

is being evaluated with these values:

{{{
method_has_no_args(func)=True func_accepts_kwargs(func)=False
func_accepts_var_args(func)=False
}}}

The methods `func_accepts_kwargs` and `func_accepts_var_args` need to be
updated to understand the `*` and `/` syntax (new since Python 3.8).
David, would you like to prepare a patch? :-)
--
Ticket URL: <https://code.djangoproject.com/ticket/35179#comment:2>

Reply all
Reply to author
Forward
0 new messages