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

2024-02-09 Thread Django
#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: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d8f130ac3-883a3570-67d7-4d11-9eb0-ccb0b89181cb-00%40eu-central-1.amazonses.com.


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

2024-02-09 Thread Django
#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: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d8e9e5b1b-b9981a67-b7ff-44fb-9511-801aafee3906-00%40eu-central-1.amazonses.com.


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

2024-02-09 Thread Django
#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):

 * summary:  Admindocs omits model methods containing only keyword-only
 arguments =>
 Admindocs treats model some model methods containing positional-only
 arguments or keyword-only arguments as attributes


Old description:

> Given the model:
>
> {{{
> class Foo(Model):
> def arg_and_kwarg_only_method(self, arg, *, kwarg): ...
> def kwarg_only_method(self, *, kwarg): ...
> }}}
>
> The method `arg_and_kwarg_only_method()` will be documented but
> `kwarg_only_method()` will be omitted.

New description:

 Given the model:

 {{{
 class Foo(Model):
 def arg_kwarg_method(self, arg, kwarg=None): ...
 def posarg_only_method(self, posarg, /): ...
 def kwarg_only_method(self, *, kwarg): ...
 def posarg_only_and_kwarg_only_method(self, posarg, /, *, kwarg): ...
 def posarg_only_and_arg_and_kwarg_only_method(self, posarg, /, arg, *,
 kwarg): ...
 }}}

 The following are documented as methods:
  - `arg_kwarg_method()`
  - `posarg_only_method()`
  - `posarg_only_and_kwarg_only_method()`

 The following are documented as attributes:
  - `kwarg_only_method()`
  - `posarg_only_and_arg_and_kwarg_only_method()`

--
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d8e9cb5bc-e6289479-ae4a-420d-b4c9-eda0fcbf95ea-00%40eu-central-1.amazonses.com.