pythondjangopycharm

How can I fix the "Calling format_html() without passing args or kwargs is deprecated." in PyCharm?


I have the following code:

def _demo_preview_message(request):
    if not getattr(settings, 'IS_DEMO', False):
        return
    last = DemoEmail.objects.order_by('-id').first()
    if last:
        messages.success(
            request=request,
            message=format_html("Email queued (demo). <a href='{}'>Preview</a>",
                                reverse('demo_outbox_detail', args=[last.pk]))
        )

At the line:

message=format_html("Email queued (demo). <a href='{}'>Preview</a>",
                                reverse('demo_outbox_detail', args=[last.pk]))

PyCharm gives me the following message:

Calling format_html() without passing args or kwargs is deprecated.

How can I fix this?

Later edit:

  1. Only PyCharm gives me this warning, in the Problems tab (Alt+6). When I run the code, everything is fine.
  2. This is the only place in my project where I have format_html

Solution

  • Seems to be a code analysis issue from PyCharms side so no need to fix this if everything works fine when ran.
    If this really bothers you, you could maybe disable it in pycharm: Preferences -> Editor -> Inspections