How to configure Microsoft Pylance to not use stub files (.pyi) for django?

Viewed 2614

I am doing Django development using visual studio code on mac os with microsoft's pylance extension installed. Following is the version specification of my eco system :

OS -> MacOS Mojave
django -> 3.1.5
visual studio code -> 1.52.1
Microsoft Pylance -> 2021.1.2 Release (latest) 

We use JSONField from django's 3.1.5 version. Pylance use stub files for django located at extensions/ms-python.vscode-pylance-2021.1.2/dist/bundled/stubs/djano/db/models/__init__.pyi

enter image description here

I can clearly see that stubs file mentioned is not up-to-date. Because of that, vscode is not able to resolve reference to models.JSONField. While for other libraries like jsonschema , it simply relies on their __init__.py. That's what I want.

enter image description here

I checked what all can be configured on official page of Pylance but I did not find any suitable configuraiton. https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance

I am considering following options :

  1. Delete stubs file/directory for django, I don't know what will be repercussions.
  2. Manually setting python.analysis.extraPaths to my virtualenv path.

I am looking for a more organic solution and I'll provide the result of the above experiments in the comments.

Thanks !

0 Answers
Related