Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obsolete bundled django-stubs #4562

Closed
sronveaux opened this issue Jun 30, 2023 · 2 comments
Closed

Obsolete bundled django-stubs #4562

sronveaux opened this issue Jun 30, 2023 · 2 comments
Assignees
Labels
typestub Issue relating to our bundled type stubs

Comments

@sronveaux
Copy link

Hello,

I was wondering how and when bundled django-stubs were updated as I'm using quite a recent version of pylance but came across an incorrect type definition that was corrected in the official django-stubs repo... in 2021 !

Here's a snapshot where you can see the version used and the problematic type definition (the second definition of atomic):

pylance

And here's a snapshot where you can see the history of this file and that a durable argument was added to atomic on Apr 13, 2021

github

This wasn't removed inbetween and is still present today in the official django-stubs. Can you help me better understand how pylance team manages inclusion of those stubs or best-practices to keep them up-to-date?

Many thanks in advance,

Sébastien

@debonte
Copy link
Contributor

debonte commented Jun 30, 2023

The Django stubs that are bundled with Pylance come from https://github.com/sbdchd/django-types not from https://github.com/typeddjango/django-stubs, which I assume is what you mean by the "official" stubs. Even those are community maintained btw.

The problem with django-stubs is that many of its annotations assume that you are using mypy plus the django-stubs mypy plug-in, and therefore there are issues with the stubs when using other type checkers.

I can't say why django-types is lagging so far behind django-stubs. It's not dead. They are still merging several PRs per month.

There's an open issue suggesting that django-stubs adopt the approach used in django-types so it could work across type checkers. The issue was originally opened 2+ years ago though. If you, or anyone reading this, are motivated to make this change I'm sure you'd make a lot of people happy.

In the meantime, you could try using django-stubs to see if it works better for your personal needs. I don't recall what particular problems caused us to switch to django-types, but maybe your particular codebase won't hit those problems. One approach would be to put django-stubs in your stubPath. See https://microsoft.github.io/pyright/#/configuration?id=main-configuration-options.

@debonte debonte closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2023
@debonte debonte added the typestub Issue relating to our bundled type stubs label Jun 30, 2023
@sronveaux
Copy link
Author

Hi @debonte and thanks for the fast reply!

I was aware that those two existed but never thought that django-types would also live in a directory called django-stubs.
It's good to hear that Pylance includes django-types for now, knowing, as you said, that django-stubs relies on mypy plug-in system to work correctly. I wasn't aware you switched to those but think it's a choice that currently makes sense.

I'm afraid I'm not enough in type checking to dare contribute to such a work but I just created a small PR to add the missing parameter I've found inside django-types.

Thanks again for your reply and hope your answer can help others know what is used inside Pylance under the hood!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typestub Issue relating to our bundled type stubs
Projects
None yet
Development

No branches or pull requests

2 participants