jazzband / django-debug-toolbar

A configurable set of panels that display various debug information about the current request/response.
https://django-debug-toolbar.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
8.07k stars 1.05k forks source link

Type hints: toolbar/middleware #1848

Open leandrodesouzadev opened 11 months ago

leandrodesouzadev commented 11 months ago

Description

This PR adds type hints to the middleware and toolbar modules

Fixes #1705

Checklist:

leandrodesouzadev commented 11 months ago

I haven't touched on the changes.rst file. I wasn't quite sure if it's required for this type of change.

leandrodesouzadev commented 11 months ago

I'm not quite sure how to resolve this lint error. Can anyone give me a hint?

matthiask commented 11 months ago

@leandrodesouzadev The automatically generated documentation for panels (https://django-debug-toolbar.readthedocs.io/en/latest/panels.html#debug_toolbar.panels.Panel) will contain a reference to your new GetResponse stub. The stub itself isn't documented however, so Sphinx doesn't know where GetResponse should point to.

Something like this fixes it:

diff --git a/docs/panels.rst b/docs/panels.rst
index db4e9311..f2fe35c0 100644
--- a/docs/panels.rst
+++ b/docs/panels.rst
@@ -352,6 +352,8 @@ There is no public CSS API at this time.

     .. automethod:: debug_toolbar.panels.Panel.run_checks

+.. autoclass:: debug_toolbar._stubs.GetResponse
+
 .. _javascript-api:

 JavaScript API

I'm not sure if that's what we want. Maybe there's a different way to specify the type which doesn't require the GetResponse class to be documented as well? Or maybe documenting the stub itself (as a temporary measure, until Django ships type hints?) would be the way to go?

leandrodesouzadev commented 11 months ago

Will definitely take a look into it