From b2958e2b4c759c7614b1d42cc87693318dfe3677 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Thu, 16 Jan 2025 16:00:14 +0000 Subject: [PATCH] Work around Sphinx failing to resolve HttpRequest in type annotations Fixes #12777 --- docs/conf.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index e227e870c5..a7b2f189cc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -72,8 +72,7 @@ autodoc_type_aliases = { nitpick_ignore = [ # Sphinx currently cannot resolve type hint names, warns "target not found": ("py:class", "wagtail.images.models.Filter"), - ("py:class", "HttpRequest"), - ("py:class", "RouteResult"), + ("py:class", "wagtail.url_routing.RouteResult"), ("py:class", "wagtail.blocks.base.Block"), ("py:class", "wagtail.blocks.field_block.BaseChoiceBlock"), ("py:class", "wagtail.blocks.field_block.ChooserBlock"), @@ -400,3 +399,9 @@ def setup(app): rolename="lookup", indextemplate="pair: %s; field lookup type", ) + + # Stop Sphinx from looking in the wrong place for HttpRequest when resolving + # type annotations - see https://github.com/wagtail/wagtail/pull/12777 + from django.http import HttpRequest + + HttpRequest.__module__ = "django.http"