(app: WSGIApplication)
| 430 | |
| 431 | |
| 432 | def _wrap_django_static(app: WSGIApplication) -> WSGIApplication: |
| 433 | # Wrap the Django WSGI app with StaticFilesHandler so that requests to |
| 434 | # STATIC_URL are served from source directories via Django's staticfiles |
| 435 | # finders, without needing collectstatic to have been run. |
| 436 | try: |
| 437 | from django.conf import ( # noqa: PLC0415 # pyright: ignore[reportMissingImports, reportMissingTypeStubs] |
| 438 | settings as django_settings, # pyright: ignore[reportUnknownVariableType, reportMissingTypeStubs] |
| 439 | ) |
| 440 | |
| 441 | installed = getattr(django_settings, "INSTALLED_APPS", []) # pyright: ignore[reportUnknownArgumentType] |
| 442 | if "django.contrib.staticfiles" not in installed: |
| 443 | return app |
| 444 | |
| 445 | from django.contrib.staticfiles.handlers import ( # noqa: PLC0415 # pyright: ignore[reportMissingImports, reportMissingTypeStubs] |
| 446 | StaticFilesHandler, # pyright: ignore[reportUnknownVariableType] |
| 447 | ) |
| 448 | |
| 449 | if result := _handle_manifest(app): |
| 450 | return result |
| 451 | |
| 452 | return cast("WSGIApplication", StaticFilesHandler(app)) |
| 453 | except ImportError: |
| 454 | return app |
| 455 | |
| 456 | |
| 457 | def _handle_manifest(app: WSGIApplication) -> WSGIApplication | None: |
no test coverage detected