Skip to content

Superfluous comment inside DebugToolbarMiddleware.__call__ #2281

@rnazali

Description

@rnazali

The DebugToolbarMiddleware.__call__ method contains seemingly superfluous comments that might be simplified - tough may be trivial - for better readability.

def __call__(self, request: HttpRequest) -> HttpResponse:
# Decide whether the toolbar is active for this request.
if self.async_mode:
return self.__acall__(request)
# Decide whether the toolbar is active for this request.
show_toolbar = get_show_toolbar(async_mode=self.async_mode)

Considering that DebugToolbarMiddleware.__acall__ (the async one just beneath) also includes the same comment:

async def __acall__(self, request: HttpRequest) -> HttpResponse:
# Decide whether the toolbar is active for this request.
show_toolbar = get_show_toolbar(async_mode=self.async_mode)

A change to something like this might be more concise:

    def __call__(self, request: HttpRequest) -> HttpResponse:
        # Decide whether the toolbar is active for this request.
        if self.async_mode:
            return self.__acall__(request)
        show_toolbar = get_show_toolbar(async_mode=self.async_mode)

I'm keen to creating a PR, but I would appreciate what others think before trying to revert something that may be intended in the first place for some reason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions