Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Typing
  3. djangorestframework-stubs

djangorestframework-stubs

MITPython3.17.0

PEP-484 type stubs and mypy plugin for Django REST Framework to enable static type checking.

GitHubGitHub
538 stars140 forks0 contributors

What is djangorestframework-stubs?

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.

Target Audience

Django developers building REST APIs with Django REST Framework who want to add static type checking to their codebase for better reliability and maintainability.

Value Proposition

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.

Overview

PEP-484 stubs for django-rest-framework

Use Cases

Best For

  • Adding static type checking to existing Django REST Framework projects
  • Improving code safety and maintainability in DRF-based APIs
  • Enabling IDE autocompletion and type hints for DRF classes
  • Catching type-related bugs early in the development cycle
  • Integrating mypy into Django REST Framework workflows
  • Developing large-scale Django APIs with confidence in type consistency

Not Ideal For

  • Projects using Python versions older than 3.10
  • Developers relying on type checkers other than mypy, such as pyright or pytype
  • Teams working on small or rapidly prototyped APIs where type annotation overhead outweighs benefits
  • Codebases with highly dynamic serialization patterns that resist static typing

Pros & Cons

Pros

Comprehensive Type Stubs

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.

Enhanced Mypy Plugin

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.

Active Community Support

Backed by an active community on Gitter and GitHub with regular contributions, ensuring ongoing updates and bug fixes, as mentioned in the project details.

Modern Python Compatibility

Supports Python 3.10 and above, aligning with modern Python development practices and ensuring compatibility with recent language features.

Cons

Mypy-Only Ecosystem

The stubs and plugin are tailored specifically for mypy, limiting flexibility for teams that prefer or require other type checkers like pyright.

Python Version Restriction

Requires Python 3.10 or newer, excluding legacy projects stuck on older Python versions, as noted in the README's compatibility statement.

Manual Configuration Needed

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.

Incomplete Type Inference

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.

Frequently Asked Questions

Quick Stats

Stars538
Forks140
Contributors0
Open Issues54
Last commit3 days ago
CreatedSince 2018

Tags

#type-stubs#static-typing#pep484#python#api-development#mypy#type-checking#pep-484#backend#django#django-rest-framework

Built With

M
Mypy
P
Python

Included in

Typing2.0k
Auto-fetched 18 hours ago

Related Projects

typeshedtypeshed

Collection of library stubs for Python, with static types

Stars5,095
Forks2,061
Last commit22 hours ago
django-stubsdjango-stubs

PEP-484 stubs for Django

Stars1,962
Forks565
Last commit23 hours ago
asgirefasgiref

ASGI specification and utilities

Stars1,624
Forks252
Last commit5 days ago
torchtypingtorchtyping

Type annotations and dynamic checking for a tensor's shape, dtype, names, etc.

Stars1,484
Forks43
Last commit1 year ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub