torchbox / django-pattern-library

UI pattern libraries for Django templates
https://torchbox.github.io/django-pattern-library/
BSD 3-Clause "New" or "Revised" License
360 stars 44 forks source link

Improve handling of non-string values for 'override_tag's 'default_html' argument #224

Closed alxbridge closed 7 months ago

alxbridge commented 1 year ago

Description

Fixes #211

Raises a (more) meaningful TypeError if a call is made to override_tag with something other than a string as the default_html arg. This raised error provides some context for the bad call, which was not provided in the traceback when thrown directly by Django >= 4.0.

If run in Django < 4.0, this PR causes a warning to be logged instead, giving developers on those older versions advance warning of the change.

Checklist

zerolab commented 1 year ago

fwiw, I tested the fix the warning suggests on an active project and that fixed the PL issue

alxbridge commented 1 year ago

NB I've pushed an updated version of this PR with an extra commit to allow the tox config to run. However, it looks like there are other PRs to address this same issue in other ways: if preferable I can remove this again, now I can see all checks have passed.

alxbridge commented 8 months ago

@bcdickinson I believe I've addressed the changes you requested - please could you re-review?