Modify the library imports inline with your code

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the dependencies category.

Last Updated: 2024-03-02

If a library (L2) changes where they a function, and you have another dependency (L1) that expects this library to be at this changed location, then try modifying the library import early in the program before L1 is required. Then L1 should be able to import from its old expected location, without the need for you to muck with forks and dependency versions.

import django
from django.utils.encoding import smart_str
django.utils.encoding.smart_text = smart_str