Opened 5 years ago

Closed 5 years ago

#13193 closed (wontfix)

Reverse should ignore unused kwargs like Python string interpolation

Reported by: trey@… Owned by: nobody
Component: Core (Other) Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

Python does a good job ignoring unused kwargs with string formatting, django should as well.

url(r'^member/(?P<id>\d+)/$', 'edit', name="edit"),

reverse('edit', kwargs={'id': 3}) #SUCCESS
reverse('edit', kwargs={'id': 3, 'random key': 'stuff'}) #FAILS

Attachments (3)

reverse_ignore_kwargs.diff (640 bytes) - added by anonymous 5 years ago.
reverse_ignore_kwargs.2.diff (626 bytes) - added by anonymous 5 years ago.
reverse_ignore_kwargs.3.diff (625 bytes) - added by trey@… 5 years ago.

Download all attachments as: .zip

Change History (10)

Changed 5 years ago by anonymous

comment:1 Changed 5 years ago by anonymous

  • milestone 1.2 deleted
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 5 years ago by Alex

I think better would be to require that the RHS set is a strict superset of the LHS set.

Changed 5 years ago by anonymous

comment:3 Changed 5 years ago by anonymous

second patch makes sure params is a subset of kwargs. This is officially a one character change :)

comment:4 Changed 5 years ago by trey@…

PS: anonymous posts are me

comment:5 Changed 5 years ago by Alex

  • Component changed from Uncategorized to Core framework
  • Has patch set
  • Needs tests set

Changed 5 years ago by trey@…

comment:6 Changed 5 years ago by trey@…

3rd diff should work a lot better, we don't want to skip if the sets are equal. My logic was a bit twisted, should be good now though.

comment:7 Changed 5 years ago by russellm

  • Resolution set to wontfix
  • Status changed from new to closed

I disagree that this would be a good thing. For example, this could give you the impression that you are reversing to a view that will honor to 'random key', when in fact the argument will be silently ignored.

If you want to argue your case for this, open a discussion on django-developers.

Note: See TracTickets for help on using tickets.
Back to Top