Skip to content

Type hints: utils module #1707

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
typing: Removes typing.TypedDict to keep the project python3.7 comp…
…atible
  • Loading branch information
leandrodesouzadev committed Nov 14, 2022
commit 66112c6f836259cca1d38261b4c66537a25d02c2
13 changes: 1 addition & 12 deletions debug_toolbar/stubs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, List, NamedTuple, Optional, Tuple, TypedDict
from typing import Any, List, NamedTuple, Optional, Tuple

from django import template as dj_template
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthiask Admittedly I haven't done typing in a project of my own that requires a stubs file. I'm unsure how I feel about a single stub file without docs or some way to determine if they're used someplace. However, I think I'm okay with us using this until we find it doesn't work.

Thoughts?


Expand All @@ -15,17 +15,6 @@ class InspectStack(NamedTuple):
TidyStackTrace = List[Tuple[str, int, str, str, Optional[Any]]]


class DebugContext(TypedDict):
num: int
content: str
highlight: bool


class TemplateContext(TypedDict):
name: str
context: List[DebugContext]


class RenderContext(dj_template.context.RenderContext):
template: dj_template.Template

Expand Down
2 changes: 1 addition & 1 deletion debug_toolbar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_template_info() -> Optional[Dict[str, Any]]:
return template_info


def get_template_context(node, context, context_lines=3) -> stubs.TemplateContext:
def get_template_context(node, context, context_lines=3) -> Dict[str, Any]:
line, source_lines, name = get_template_source_from_exception_info(node, context)
debug_context = []
start = max(1, line - context_lines)
Expand Down