#31070: Add a check for URLconfs that mix named and unnamed capture groups
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Baptiste
| Mispelon
Type: New feature | Status: assigned
Component: Core (System | Version: master
checks) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):
* needs_better_patch: 0 => 1
* stage: Unreviewed => Accepted
Comment:
Hi Baptiste. Thanks for this.
I think on the main issue here, a warning would be OK. So, yep, let´s
accept.
> As a remedy, it would suggest converting the unnamed groups to non-
capturing groups ((?:\d+) syntax with our current example.
I don´t understand the reasoning for this suggestion. A non-capturing
group would not be returned by the `groupdict()` call on the match, so
would not be passed to the view.
So (I think) it´s not what users want/need/should be doing. Can you
clarify?
Rather (I think) in the mixed case, we should just use "Prefer named
capturing groups", assuming folks know what they´re doing if they´ve used
just unnamed groups.
What do you think? (Perhaps I´m just missing something...)
On the second suggestion, yes it would be a separate ticket but, I don´t
see the utility. All CBVs end up with a rather generic `Signature(self,
request, *args, **kwargs)`, so a check here isn´t going to catch much,
(again) I think... ?
--
Ticket URL: <https://code.djangoproject.com/ticket/31070#comment:3>
Django <https://code.djangoproject.com/>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.6897814d8b31b4faf23bdaaa5e890cc1%40djangoproject.com.