{"id":13634404,"url":"https://github.com/typeddjango/djangorestframework-stubs","last_synced_at":"2025-04-05T23:02:27.548Z","repository":{"id":37405891,"uuid":"157137780","full_name":"typeddjango/djangorestframework-stubs","owner":"typeddjango","description":"PEP-484 stubs for django-rest-framework","archived":false,"fork":false,"pushed_at":"2025-03-31T04:14:17.000Z","size":769,"stargazers_count":487,"open_issues_count":68,"forks_count":123,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-04T09:13:09.284Z","etag":null,"topics":["django","django-rest-framework","mypy","pep484","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/typeddjango.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"typeddjango","open_collective":"typeddjangoorg"}},"created_at":"2018-11-12T01:07:16.000Z","updated_at":"2025-04-04T01:05:18.000Z","dependencies_parsed_at":"2023-12-08T15:09:34.377Z","dependency_job_id":"15b55f5e-6ed1-462a-b760-808a30fbdece","html_url":"https://github.com/typeddjango/djangorestframework-stubs","commit_stats":{"total_commits":541,"total_committers":77,"mean_commits":7.025974025974026,"dds":0.7744916820702403,"last_synced_commit":"c78da6d315f0994ad472d2c2406ae5718ef36057"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeddjango%2Fdjangorestframework-stubs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeddjango%2Fdjangorestframework-stubs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeddjango%2Fdjangorestframework-stubs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeddjango%2Fdjangorestframework-stubs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typeddjango","download_url":"https://codeload.github.com/typeddjango/djangorestframework-stubs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249908,"owners_count":20908270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-rest-framework","mypy","pep484","python"],"created_at":"2024-08-01T23:01:03.998Z","updated_at":"2025-04-05T23:02:27.499Z","avatar_url":"https://github.com/typeddjango.png","language":"Python","funding_links":["https://github.com/sponsors/typeddjango","https://opencollective.com/typeddjangoorg"],"categories":["Django Utilities","Stub packages"],"sub_categories":[],"readme":"\u003cimg src=\"https://mypy-lang.org/static/mypy_light.svg\" alt=\"mypy logo\" width=\"300px\"/\u003e\n\n# pep484 stubs for Django REST framework\n\n[![Build status](https://github.com/typeddjango/djangorestframework-stubs/workflows/test/badge.svg?branch=master\u0026event=push)](https://github.com/typeddjango/djangorestframework-stubs/actions?query=workflow%3Atest)\n[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\n[![Gitter](https://badges.gitter.im/mypy-django/Lobby.svg)](https://gitter.im/mypy-django/Lobby)\n[![StackOverflow](https://shields.io/badge/ask-stackoverflow-orange?logo=stackoverflow)](https://stackoverflow.com/questions/tagged/django-stubs?tab=Active)\n\n\nMypy stubs for [Django REST Framework](https://pypi.org/project/djangorestframework/).\nSupports Python 3.8 and up.\n\n## Installation\n\n```bash\npip install djangorestframework-stubs[compatible-mypy]\n```\n\nTo make mypy aware of the plugin, you need to add\n\n```ini\n[mypy]\nplugins =\n    mypy_drf_plugin.main\n```\n\nin your `mypy.ini` file.\n\n## FAQ\n\n### Model instance is inferred as `Any` instead of my `Model` class\n\nWhen subclassing `ModelSerializer`, add a [type argument](https://peps.python.org/pep-0484/#generics) to type-hint the related model class, for example:\n\n```python\nclass MyModelSerializer(serializers.ModelSerializer[MyModel]):\n    class Meta:\n        model = MyModel\n        fields = (\"id\", \"example\")\n```\n\nWhich 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]`.\n\n## To get help\n\nWe have Gitter here: \u003chttps://gitter.im/mypy-django/Lobby\u003e\nIf you think you have more generic typing issue, please refer to \u003chttps://github.com/python/mypy\u003e and their Gitter.\n\n## Contributing\n\nThis project is open source and community driven. As such we encourage contributions big and small. You can contribute by doing any of the following:\n\n1. Contribute code (e.g. improve stubs, add plugin capabilities, write tests etc) - to do so please follow the [contribution guide](./CONTRIBUTING.md).\n2. Assist in code reviews and discussions in issues.\n3. Identify bugs and issues and report these\n\nYou can always also reach out in gitter to discuss your contributions!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypeddjango%2Fdjangorestframework-stubs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypeddjango%2Fdjangorestframework-stubs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypeddjango%2Fdjangorestframework-stubs/lists"}