Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Add detection for unimported modules/packages used as a base for classes #1955

Open
@erinxocon

Description

@erinxocon

This may have further implications and may actually be a bug but I will describe here.

from django.shortcuts import render

@method_decorator(staff_member_required, name='dispatch')
class IndexView(TemplateView):

    def get(self, request):
        pass

The above file will cause django to fail when it parses since it can't find TemplateView. Where the bug may be is that the language server does not flag this as a missing import. I honestly can't say if Jedi does as I haven't used it on any project for months. Anyways since this is not flagged by the engine you can not use the auto import feature! I can get around this by doing the following:

Screen Shot 2020-03-19 at 10 46 48 AM

Then:
Screen Shot 2020-03-19 at 10 46 12 AM

Then I can remove the t = TemplateView and everything is good. So this may be a bug, since maybe the engine should detect unimported references when used as a base class definition?? But maybe that's intended; if so it'd be great it we could use the import function in that way!

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions