Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for DRF 3.15, drop Django <4.2 and DRF <3.14 #186

Merged
merged 14 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- python-version: 3.7
- python-version: 3.8
- python-version: 3.9
- python-version: "3.10"
- python-version: "3.11"
- python-version: "3.12"

env:
PYTHON: ${{ matrix.python-version }}
Expand All @@ -32,7 +33,7 @@ jobs:
- name: Test with tox
run: tox
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: PYTHON
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ The following relations are supported:
Requirements
============

- Python (3.7, 3.8, 3.9, 3.10, 3.11)
- Django (2.2, 3.0, 3.1, 3.2, 4.0, 4.1, 4.2)
- djangorestframework (3.8+)
- Python (3.8, 3.9, 3.10, 3.11, 3.12)
- Django (4.2, 5.0)
- djangorestframework (3.14+)

Installation
============
Expand Down
11 changes: 3 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,24 @@ def get_version(package):
},
include_package_data=True,
zip_safe=False,
python_requires='>=3.7',
python_requires='>=3.8',
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
'Framework :: Django :: 5.0',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Internet :: WWW/HTTP',
]
)
7 changes: 4 additions & 3 deletions tests/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,10 @@ class Meta:
class UFMChildSerializerForValidatorMessage(UniqueFieldsMixin,
serializers.ModelSerializer):
field = serializers.CharField(validators=[
UniqueValidator(queryset=models.UFMChild.objects.all(),
message=UNIQUE_ERROR_MESSAGE
)
UniqueValidator(
queryset=models.UFMChild.objects.all(), # type: ignore[attr-defined]
message=UNIQUE_ERROR_MESSAGE,
)
])

class Meta:
Expand Down
38 changes: 10 additions & 28 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,34 @@ DJANGO_SETTINGS_MODULE = tests.settings

[tox]
envlist =
py{37,38}-dj{22}-drf{38,39,310,311}-{pytest,mypy}
py{37,38}-dj{30}-drf{310,311}-{pytest,mypy}
py{37,38,39,310,311}-dj{31,32}-drf{311,312,313,314}-{pytest,mypy}
py{38,39,310,311}-dj{40,41}-drf{313,314}-{pytest,mypy}
py{38,39,310,311}-dj{42}-drf{314}-{pytest,mypy}
py{38,39,310,311,312}-dj42-drf{314,315}-pytest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@browniebroke Why do you remove mypy checks here and in the next line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding was that DRF stubs (and django-stubs) are now linked to a specific version of DRF and Django. So you should ideally have stubs version == DRF version. This was changed in https://github.com/typeddjango/djangorestframework-stubs/releases/tag/3.14.0 and https://github.com/typeddjango/django-stubs/releases/tag/4.2.0

When you install djangorestframework-stubs==3.15.*, it installs django-stubs==5.0.*, which are for DRF 3.15 and Django 5.0 respectively. Although I just noticed that django-stubs=5.0.x has "partial" support for Django 4.2...

I suppose the problem with running mypy against the wrong versions is that the type check won't find type issues if the stubs are for a different version? What I mean is that if a Django API changed its signature between 4.2 and 5.0, but the stubs used by mypy are for v5, mypy won't detect the problem with 4.2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try to add them back if you still want them?

py{310,311,312}-dj50-drf{314,315}-pytest
py312-dj50-drf315-mypy
skip_missing_interpreters = true

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.12: py312
django =
2.2: dj22
3.0: dj30
3.1: dj31
3.2: dj32
4.0: dj40
4.1: dj41
4.2: dj42
5.0: dj50

[testenv]
setenv =
PYTHONDONTWRITEBYTECODE=1
PYTHONWARNINGS=once
deps =
dj22: Django>=2.2,<2.3
dj30: Django>=3.0,<3.1
dj31: Django>=3.1,<3.2
dj32: Django>=3.2a1,<4.0
dj40: Django>=4.0,<4.1
dj41: Django>=4.1,<4.2
dj42: Django>=4.2,<5.0
drf38: djangorestframework>=3.8.0,<3.9
drf39: djangorestframework>=3.9.0,<3.10
drf310: djangorestframework>=3.10.0,<3.11
drf311: djangorestframework>=3.11,<3.12
drf312: djangorestframework>=3.12,<3.13
drf313: djangorestframework>=3.13,<3.14
dj50: Django>=5.0,<5.1
drf314: djangorestframework>=3.14,<3.15
drf315: djangorestframework>=3.15,<3.16
pytest: -rrequirements.txt
mypy: git+https://github.com/typeddjango/djangorestframework-stubs.git@946c7d60aaecdc9ef307f5e1f8eb55f7083ffb16#egg=djangorestframework-stubs
mypy: djangorestframework-stubs
mypy: djangorestframework-stubs[compatible-mypy]>=3.15,<3.16
commands=
pytest: pytest --cov drf_writable_nested --cov-report=xml
mypy: mypy example
mypy: mypy .
mypy: mypy --show-traceback example
mypy: mypy --show-traceback .
Loading