django-stubs
django-stubs copied to clipboard
django-stubs breaks PyCharm code completion in some contexts
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
Hi! I think this issue is on PyCharm's side: https://youtrack.jetbrains.com/issue/PY-37744/django-stubs-breaks-code-completion (do add a :+1: vote if you have an account there)
Maksim Kurnikov reached out to them, but according to this reply there is nothing we can do on our side.
I'll leave this bug open so if anyone else is struggling with it, it's easier to find
Looks like PY-37744 has been just recently fixed by JetBrains and will be part of the next PyCharm release (and IntelliJ Python plugin).