Opened 14 months ago

Closed 3 weeks ago

#36523 closed Cleanup/optimization (fixed)

Implement helper method to find module path of value

Reported by: Jake Howard Owned by: Vimal Sahani
Component: Utilities Version: dev
Severity: Normal Keywords:
Cc: Jake Howard 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 Jacob Walls)

Finding the module path for where a given class or function is defined is functionality used in a few places across the Django codebase. Whilst in the majority of cases, f"{val.__module__}.{val.__qualname__}" is enough, there are some cases it's not.

As part of #35859, a few more cases of this pattern are being added to the codebase. I think we're now at the point where it makes sense to extract this out to a helper function somewhere in django.utils. The implementation in django.migrations.serializer.TypeSerializer seems to be the most robust, however will want some more thorough testing based on different input types.

Change History (15)

comment:1 by Jake Howard, 14 months ago

Probably worth holding off on this ticket until #35859 is merged, so all uses can be covered.

comment:2 by Natalia Bidart, 14 months ago

Component: UncategorizedUtilities
Easy pickings: unset
Triage Stage: UnreviewedSomeday/Maybe
Version: dev

Thank you Jake for creating the ticket. Could please enumerate the locations of where this functionality is found?

comment:3 by shrutisachan08, 14 months ago

Owner: set to shrutisachan08
Status: newassigned
Version 0, edited 14 months ago by shrutisachan08 (next)

comment:4 by Jake Howard, 13 months ago

Cc: Jake Howard added

That sounds like the right approach to me - thanks for picking this up!

comment:5 by Jacob Walls, 6 months ago

Triage Stage: Someday/MaybeAccepted

#35859 was merged.

comment:8 by Jacob Walls, 3 weeks ago

Description: modified (diff)

comment:9 by Jacob Walls, 3 weeks ago

Has patch: set

comment:10 by Jacob Walls, 3 weeks ago

Owner: changed from shrutisachan08 to Vimal Sahani

comment:11 by Jacob Walls, 3 weeks ago

Patch needs improvement: set

comment:12 by Jacob Walls, 3 weeks ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:13 by Jacob Walls, 3 weeks ago

Needs tests: set
Triage Stage: Ready for checkinAccepted

comment:14 by Jacob Walls, 3 weeks ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin

comment:15 by Jacob Walls <jacobtylerwalls@…>, 3 weeks ago

Resolution: fixed
Status: assignedclosed

In 0398417c:

Fixed #36523 -- Added django.utils.module_loading.qualname() helper.

Thanks Jake Howard for the reivew.

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