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

Testing stubs against Django source code #405

Open
mkurnikov opened this issue Jun 21, 2020 · 1 comment · May be fixed by #408
Open

Testing stubs against Django source code #405

mkurnikov opened this issue Jun 21, 2020 · 1 comment · May be fixed by #408
Assignees
Labels
enhancement New feature or request

Comments

@mkurnikov
Copy link
Member

We need to start using actual Django sources to test stubs. For that, we have to merge our .pyi files inside the .py files of Django.

There's a library called LibCST https://github.com/Instagram/LibCST, which allows traversing and modifying Python source code. It's new, Python 3 only, covered with type annotations and well-maintained by Instagram. I think we should use it as a base for our merging tool, instead of
https://github.com/ambv/retype
https://github.com/google/pytype/tree/master/pytype/tools/merge_pyi
which are both lib2to3 based.

I used it in the #288 to make an example script to add stubs versioning.

It even has some built-in support for this particular task via https://libcst.readthedocs.io/en/latest/codemods.html#libcst.codemod.visitors.ApplyTypeAnnotationsVisitor

The first step here is to make a simple script that uses this visitor to apply stubs. Later, the ApplyTypeAnnotationsVisitor will be subclassed with some custom code, if we'd need any special casing.

@kszmigiel Could you take a look at it? Maybe make a script which will merge https://github.com/typeddjango/django-stubs/blob/master/django-stubs/shortcuts.pyi into the Django source, and then run mypy on top of it?
I think you should work on it before you make more changes to the stubs.

@kszmigiel
Copy link
Member

@mkurnikov Thank you for precise task description, I'll take care of it as soon as possible 😃

@intgr intgr added the enhancement New feature or request label Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

3 participants