-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Type hints/toolbar #2227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Type hints/toolbar #2227
Conversation
@tim-schilling @matthiask I suggest we start using https://github.com/typeddjango/django-stubs for the typing |
# Use OrderedDict for the _panels attribute so that items can be efficiently | ||
# removed using FIFO order in the DebugToolbar.store() method. The .popitem() | ||
# method of Python's built-in dict only supports LIFO removal. | ||
# type: ignore[var-annotated] | ||
self._panels = OrderedDict() | ||
while panels: | ||
panel = panels.pop() | ||
self._panels[panel.panel_id] = panel | ||
self.stats: dict[str, Any] = {} | ||
self.server_timing_stats: dict[str, Any] = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like there may have been a merge conflict issue.
return getattr(self.request, "csp_nonce", None) | ||
|
||
def get_panel_by_id(self, panel_id): | ||
def get_panel_by_id(self, panel_id: str) -> "Panel": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm likely missing something basic. Why can't we use -> Panel
since we have the TYPE_CHECKING
import check?
Description
This PR adds type hints to the middleware and toolbar modules. It's based on the work of @leandrodesouzadev in this pr #1848
Fixes #1705
Checklist:
docs/changes.rst
.