Skip to content

django-stubs breaks PyCharm code completion in some contexts #1807

@urzbs

Description

@urzbs

Bug report

What's wrong

Using a django project created with a the cookiecutter/django-cookiecutter/ template
(Pycharm as IDE)

autocompletion of attributes / methods of certain classes no longer work.

example tests with some class-based-views:

import logging
from django.views.generic import CreateView, DetailView, DeleteView, UpdateView

logger = logging.getLogger(__name__)


class MyCreateView(CreateView):
    # nothing is no longer autocompleted / suggested
class MyDeleteView(DeleteView):
    # nothing is no longer autocompleted / suggested
class MyUpdateView(UpdateView):
    # nothing is no longer autocompleted / suggested


# However DetailView still works with all auto-completions

class MyDetailView(DetailView):
    template_name = "" # this is still autocompleted
    def get_queryset(self) -> models.query.QuerySet[_M]: # this is still autocompleted ...

How is that should be

Like normal, you can see what the class offers for attributes / methods...

System information

  • OS: Ubuntu 22 LTS
  • IDE: Pycharm Professional 2023.1.1
  • python version: 3.10.11
  • django version: 4.2.6
  • mypy version: 1.6.1
  • django-stubs version: 4.2.6
  • django-stubs-ext version: 4.2.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedBlocked by some other PR, discussion or third party dependency.bugSomething isn't workingupstream otherBugs in other upstreams (not mypy)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions