You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+28-2Lines changed: 28 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,14 +79,13 @@ pytest
79
79
Run `bash ./scripts/stubtest.sh` to test that stubs and sources are in-line.
80
80
81
81
We have two special files to allow errors:
82
+
82
83
1.`scripts/stubtest/allowlist.txt` where we store things that we really don't care about: hacks, DRF internal utility modules, things that are handled by our plugin, things that are not representable by type system, etc
83
84
2.`scripts/stubtest/allowlist_todo.txt` where we store all errors there are right now. Basically, this is a TODO list: we need to work through this list and fix things (or move entries to real `allowlist.txt`). In the end, ideally we can remove this file
84
85
85
86
You might also want to disable `incremental` mode while working on `stubtest` changes.
86
87
This mode leads to several known problems (stubs do not show up or have strange errors).
87
88
88
-
**Important**: right now we only run `stubtest` on Python 3.12 (because it is the latest released version at the moment), any other versions might generate different outputs. Any work to create per-version allowlists is welcome.
89
-
90
89
## Submission Guidelines
91
90
92
91
The workflow for contributions is fairly simple:
@@ -96,3 +95,30 @@ The workflow for contributions is fairly simple:
96
95
3. make whatever changes you want to contribute.
97
96
4. ensure your contribution does not introduce linting issues or breaks the tests by linting and testing the code.
98
97
5. make a pull request with an adequate description.
98
+
99
+
## Releasing `djangorestframework-stubs`
100
+
101
+
1. Open a pull request that updates `setup.py` (anyone can open this PR, not just maintainers):
102
+
103
+
- Increase `version=` value within `setup(...)`. Version number `major.minor.patch` is formed as follows:
104
+
105
+
`major.minor` version must match newest supported `djangorestframework` release.
106
+
107
+
`patch` is sequentially increasing for each stubs release. Reset to `0` if `major.minor` was updated.
108
+
109
+
- Update `django-stubs>=` dependency to point to latest `django-stubs` release.
110
+
- Use pull request title "Version x.y.z release" by convention.
111
+
112
+
2. Ensure the CI succeeds. A maintainer must merge this PR. If it's just a verison bump, no need
113
+
to wait for a second maintainer's approval.
114
+
115
+
3. Maintainers need to [сreate a new GitHub release](https://github.com/typeddjango/djangorestframework-stubs/releases/new):
116
+
117
+
- Under "Choose a tag" enter the new version number. Do NOT use `v` prefix.
118
+
- Click "Generate release notes".
119
+
- Delete all release notes lines containing `by @pre-commit-ci` or `by @dependabot`, as these
120
+
are irrelevant for our users.
121
+
122
+
4. Once you feel brave enough, click "Publish release".
123
+
124
+
5. Check that the [release workflow](https://github.com/typeddjango/djangorestframework-stubs/actions/workflows/release.yml) succeeds.
Mypy stubs for [Django REST Framework](https://pypi.org/project/djangorestframework/).
11
-
Supports Python 3.8 and up.
12
+
Supports Python 3.10 and up.
12
13
13
14
## Installation
14
15
@@ -39,7 +40,7 @@ class MyModelSerializer(serializers.ModelSerializer[MyModel]):
39
40
fields = ("id", "example")
40
41
```
41
42
42
-
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]`.
43
+
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 `MyModel | typing.Sequence[MyModel] | None`.
0 commit comments