Giter VIP home page Giter VIP logo

djangorestframework-stubs's Introduction

mypy logo

pep484 stubs for Django REST framework

Build Status Checked with mypy Gitter

Mypy stubs for Django REST Framework. Supports Python 3.8 and up.

Installation

pip install djangorestframework-stubs[compatible-mypy]

To make mypy aware of the plugin, you need to add

[mypy]
plugins =
    mypy_drf_plugin.main

in your mypy.ini file.

FAQ

Model instance is inferred as Any instead of my Model class

When subclassing ModelSerializer, add a type argument to type-hint the related model class, for example:

class MyModelSerializer(serializers.ModelSerializer[MyModel]):
    class Meta:
        model = MyModel
        fields = ("id", "example")

Which means that methods where the model is being passed around will know the actual type of the model instead of being Any. The instance attribute on the above serializer will be Union[MyModel, typing.Sequence[MyModel], None].

To get help

We have Gitter here: https://gitter.im/mypy-django/Lobby If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter.

Contributing

This project is open source and community driven. As such we encourage contributions big and small. You can contribute by doing any of the following:

  1. Contribute code (e.g. improve stubs, add plugin capabilities, write tests etc) - to do so please follow the contribution guide.
  2. Assist in code reviews and discussions in issues.
  3. Identify bugs and issues and report these

You can always also reach out in gitter to discuss your contributions!

djangorestframework-stubs's People

Contributors

dependabot[bot] avatar intgr avatar mkurnikov avatar sobolevn avatar pre-commit-ci[bot] avatar github-actions[bot] avatar kalekseev avatar goldziher avatar henribru avatar brianhelba avatar landinh avatar marcinwieczorek avatar terencehonles avatar flaeppe avatar xf-fw avatar frnhr avatar nils-van-zuijlen avatar tkadur avatar palfrey avatar guldfisk avatar 4c0n avatar christianbundy avatar imamatory avatar safintim avatar stianjensen avatar stevanmilic avatar sshishov avatar richardxia avatar rafales avatar asfaltboy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.