PEP-484 type stubs and mypy plugin for Django REST Framework to enable static type checking.
djangorestframework-stubs is a collection of PEP-484 type stubs and a mypy plugin for Django REST Framework. It provides static type annotations for DRF's classes and methods, enabling developers to use type checkers like mypy to catch errors and improve code quality in their Django REST API projects.
Django developers building REST APIs with Django REST Framework who want to add static type checking to their codebase for better reliability and maintainability.
It offers comprehensive and accurate type definitions specifically tailored for DRF's patterns, along with a mypy plugin that handles DRF's unique type inference challenges, making it the go-to solution for typed Django REST development.
PEP-484 stubs for django-rest-framework
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides complete PEP-484 type annotations for all Django REST Framework classes and functions, as stated in the project description, ensuring broad coverage for static type checking.
Includes a dedicated mypy plugin that improves type inference for DRF-specific patterns like ModelSerializers, helping catch subtle errors early, as highlighted in the README.
Backed by an active community on Gitter and GitHub with regular contributions, ensuring ongoing updates and bug fixes, as mentioned in the project details.
Supports Python 3.10 and above, aligning with modern Python development practices and ensuring compatibility with recent language features.
The stubs and plugin are tailored specifically for mypy, limiting flexibility for teams that prefer or require other type checkers like pyright.
Requires Python 3.10 or newer, excluding legacy projects stuck on older Python versions, as noted in the README's compatibility statement.
Users must manually edit their mypy.ini file to add the plugin, adding setup complexity and potential for configuration errors, as per the installation instructions.
As admitted in the FAQ, certain cases like ModelSerializer instances may be inferred as Any without explicit type hints, requiring manual intervention and extra boilerplate code.