Opened 7 years ago
Last modified 3 years ago
#29299 new Cleanup/optimization
Add type hints (PEP 484) and variable annotations (PEP 526)
Reported by: | Andreas Galazis | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 2.0 |
Severity: | Normal | Keywords: | |
Cc: | Adam Johnson, Zach Borboa, Vlastimil Zíma | Triage Stage: | Someday/Maybe |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Adhering to Type hints(PEP 484) / type annotations could contribute to being more explicit / performing code analysis and checks on Django projects. Intellisense based on type annotations can also contribute to faster and less error-prone coding experience.
Typesheds will be a pain to maintain across versions. Based on my experience with typescript typings, the most immaculate situation is shipping typings within the project, even though shipping external typings is mature in that case. Nevertheless, inline typings can help Django project development as well.
Adding to the docs any future plans regarding this would be helpful to prospective developers.
Change History (13)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Component: | Uncategorized → Core (Other) |
---|---|
Summary: | Inline/Out of the box Type hints(PEP 484) and Variable annotations(PEP 526) → Add typing hinting (PEP 484) and variable annotations (PEP 526) |
Triage Stage: | Unreviewed → Someday/Maybe |
comment:3 by , 7 years ago
Cc: | added |
---|
comment:4 by , 7 years ago
Cc: | added |
---|
comment:5 by , 7 years ago
Summary: | Add typing hinting (PEP 484) and variable annotations (PEP 526) → Add type hints (PEP 484) and variable annotations (PEP 526) |
---|
comment:6 by , 7 years ago
Cc: | added |
---|
comment:7 by , 6 years ago
I am available to help with this issue. Is there a checklist of files or areas, so that I can take a few to start?
comment:8 by , 6 years ago
See comment 2 and post on the mailing list if you want to try to get a consensus on a way forward.
comment:9 by , 6 years ago
Are there any updates on this ticket?
Does Django has some roadmap for adding type hints support to Django?
comment:12 by , 3 years ago
Adding them in the framework would make changes to the framework more smooth since typings would be updated within the codebase and there will be no need for a new stub release (or waiting for the stub release).
I understand that it might involve a bit of donkey work to merge the stubs in the framework.
If we find a tool to merge it automatically, would it be acceptable?
As a sidenote, I stumbled on this:
https://pypi.org/project/retype/
comment:13 by , 3 years ago
Just to add here too, this project here is a fork of the original django-stubs
but without the mypy dependency and that works fine with pyright.
It has some interesting stuff in it, like defined a field with null=True
/null=False
automatically types it as being able to get/set None together with the field's primary type.
edit: Forgot to add the link to the repository itself: https://github.com/sbdchd/django-types
This is discussed on django-developers but a consensus on how to proceed hasn't emerged.