#36523: Implement helper method to find module path of value
-------------------------------------+-------------------------------------
Reporter: Jake Howard | Type:
| Cleanup/optimization
Status: new | Component:
| Uncategorized
Version: | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
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
https://en.wikipedia.org/wiki/Rule_of_three_(computer_programming)] 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.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36523>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.