Opened 4 years ago

Closed 4 years ago

#32572 closed Cleanup/optimization (fixed)

ResolverMatch.__repr__() doesn't handle functools.partial() nicely.

Reported by: Nick Pope Owned by: Nick Pope
Component: Core (URLs) Version: dev
Severity: Normal Keywords: __repr__
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Nick Pope)

When a partial function is passed as the view, the __repr__ shows the func argument as functools.partial which isn't very helpful, especially as it doesn't reveal the underlying function or arguments provided.

Because a partial function also has arguments provided up front, we need to handle those specially so that they are accessible in __repr__.

ISTM that we can simply unwrap functools.partial objects in ResolverMatch.__init__().

Change History (6)

comment:1 by Nick Pope, 4 years ago

Has patch: set

comment:2 by Mariusz Felisiak, 4 years ago

Resolution: wontfix
Status: assignedclosed
Type: BugCleanup/optimization

Nick, thanks for this proposition. However I agree with Tim's comment, the improvement is not worth the breaking change.

comment:3 by Nick Pope, 4 years ago

Description: modified (diff)
Resolution: wontfix
Status: closednew

Reopening with a different approach based on my comment.

comment:4 by Mariusz Felisiak, 4 years ago

Status: newassigned
Triage Stage: UnreviewedAccepted

Improving __repr__() sounds good to me.

comment:5 by Mariusz Felisiak, 4 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 41850eec:

Fixed #32572 -- Improved ResolverMatch.repr().

When a partial function was passed as the view, the repr() would
show the func argument as functools.partial which isn't very
helpful, especially as it doesn't reveal the underlying function or
arguments provided.

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