Opened 15 years ago

Closed 15 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: no UI/UX: no

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 15 years ago.
reverse_ignore_kwargs.2.diff (626 bytes ) - added by anonymous 15 years ago.
reverse_ignore_kwargs.3.diff (625 bytes ) - added by trey@… 15 years ago.

Download all attachments as: .zip

Change History (10)

by anonymous, 15 years ago

Attachment: reverse_ignore_kwargs.diff added

comment:1 by anonymous, 15 years ago

milestone: 1.2

comment:2 by Alex Gaynor, 15 years ago

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

by anonymous, 15 years ago

comment:3 by anonymous, 15 years ago

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

comment:4 by trey@…, 15 years ago

PS: anonymous posts are me

comment:5 by Alex Gaynor, 15 years ago

Component: UncategorizedCore framework
Has patch: set
Needs tests: set

by trey@…, 15 years ago

comment:6 by trey@…, 15 years ago

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 by Russell Keith-Magee, 15 years ago

Resolution: wontfix
Status: newclosed

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