Avoid a Python deprecation warning with the collections patch.

Review Request #12312 — Created May 31, 2022 and submitted — Latest diff uploaded

Information

Django Evolution
release-2.x

Reviewers

Django Evolution provides a compatibility patch to enable
collections.Callable on Python 3.10 with Django <= 2.0. To check
whether to apply the patch, we were checking for the existence of
collections.Callable and the Django version.

The first check led to a deprecation warning on modern versions of
Python, which is annoying when running on a version of Django not
susceptible to the old imports. Instead, we now check the Django version
first, avoiding the warning.

Started up a dev server and saw that the warning no longer appeared.

Diff Revision 1 (Latest)

Commits

First Last Summary ID Author
Avoid a Python deprecation warning with the collections patch.
Django Evolution provides a compatibility patch to enable `collections.Callable` on Python 3.10 with Django <= 2.0. To check whether to apply the patch, we were checking for the existence of `collections.Callable` and the Django version. The first check led to a deprecation warning on modern versions of Python, which is annoying when running on a version of Django not susceptible to the old imports. Instead, we now check the Django version first, avoiding the warning.
8b237c4f53d6fa0e10fcb30814e12047a5c9cf9d Christian Hammond
django_evolution/compat/patches/python3_10_collection_imports.py
Loading...