0
votes

So I'm having a problem with PyCharm and can't find a solution for it. It fails to recognize unresolved references:

example

The image also shows that it fails to auto-complete request.session. It only happens with .session, it works with every other attribute.

Also, this image shows that it does detect unresolved references for other stuff:

this image

I'm running it on a virtualenv, the interpreter is configured correctly and I have Django Support enabled.

Oh, and I'm using Python3 and Django 1.10.2

EDIT: Just tried it with other projects. It doesn't work with Django 1.10.x but works with Django 1.9.x

1
Should this be a bug report to PyCharm? - Jeff B
@JeffBridgman I'm not sure if it's a bug or if I'm missing something, since it was working fine yesterday. - Arnau Villoslada
I'm a loyal Jetbrains customer and they have outstanding official support channels. - Paulo Scardine
@PauloScardine I'll head there then, thank you! :) - Arnau Villoslada

1 Answers

0
votes

Well, in your 1st example request is a parameter to the dummy_view function - how would Pycharm know what type it is in order to check unresolved references (or offer auto-completion suggestions)?

You could add a check for request's type (also maybe a good idea to prevent bugs):

def dummy_view(request):
    assert isinstance(request, ExpectedClassType)

Or, since you tagged your question with python-3.x you could also use type hinting:

def dummy_view(request: ExpectedClassType):