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 Django 4.2 #711

Merged
merged 2 commits into from
Jun 21, 2023
Merged

Add support for Django 4.2 #711

merged 2 commits into from
Jun 21, 2023

Conversation

johnthagen
Copy link
Contributor

Closes #706

Closes #707

  • Add support for Django 4.2
  • Add minimum bound on Django and DRF requirement matching the minimum version tested in CI
  • Fix documentation on supported Python/Django/DRF versions (Update requirements section #706)

@johnthagen
Copy link
Contributor Author

johnthagen commented May 31, 2023

  ________________ ERROR collecting tests/test_authentication.py _________________
  ImportError while importing test module '/home/runner/work/djangorestframework-simplejwt/djangorestframework-simplejwt/tests/test_authentication.py'.
  Hint: make sure your test modules/packages have valid Python names.
  Traceback:
  .tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/rest_framework/settings.py:177: in import_from_string
      return import_string(val)
  .tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/django/utils/module_loading.py:30: in import_string
      return cached_import(module_path, class_name)
  .tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/django/utils/module_loading.py:15: in cached_import
      module = import_module(module_path)
  /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/importlib/__init__.py:127: in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
  <frozen importlib._bootstrap>:1014: in _gcd_import
      ???
  <frozen importlib._bootstrap>:991: in _find_and_load
      ???
  <frozen importlib._bootstrap>:975: in _find_and_load_unlocked
      ???
  <frozen importlib._bootstrap>:671: in _load_unlocked
      ???
  <frozen importlib._bootstrap_external>:843: in exec_module
      ???
  <frozen importlib._bootstrap>:219: in _call_with_frames_removed
      ???
  .tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/rest_framework/renderers.py:17: in <module>
      from django.http.multipartparser import parse_header
  E   ImportError: cannot import name 'parse_header' from 'django.http.multipartparser' (/home/runner/work/djangorestframework-simplejwt/djangorestframework-simplejwt/.tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/django/http/multipartparser.py)
  
  During handling of the above exception, another exception occurred:
  /opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/importlib/__init__.py:127: in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
  tests/test_authentication.py:6: in <module>
      from rest_framework.test import APIRequestFactory
  .tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/rest_framework/test.py:139: in <module>
      class APIRequestFactory(DjangoRequestFactory):
  .tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/rest_framework/test.py:140: in APIRequestFactory
      renderer_classes_list = api_settings.TEST_REQUEST_RENDERER_CLASSES
  .tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/rest_framework/settings.py:225: in __getattr__
      val = perform_import(val, attr)
  .tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/rest_framework/settings.py:168: in perform_import
      return [import_from_string(item, setting_name) for item in val]
  .tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/rest_framework/settings.py:168: in <listcomp>
      return [import_from_string(item, setting_name) for item in val]
  .tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/rest_framework/settings.py:180: in import_from_string
      raise ImportError(msg)
  E   ImportError: Could not import 'rest_framework.renderers.MultiPartRenderer' for API setting 'TEST_REQUEST_RENDERER_CLASSES'. ImportError: cannot import name 'parse_header' from 'django.http.multipartparser' (/home/runner/work/djangorestframework-simplejwt/djangorestframework-simplejwt/.tox/py38-dj42-drf313-pyjwt2-tests/lib/python3.8/site-packages/django/http/multipartparser.py).

https://docs.djangoproject.com/en/4.2/releases/4.2/#miscellaneous

The undocumented django.http.multipartparser.parse_header() function is removed. Use django.utils.http.parse_header_parameters() instead.

It looks like DRF 3.13 is not compatible with Django 4.2.

@johnthagen
Copy link
Contributor Author

johnthagen commented May 31, 2023

@Andrew-Chen-Wang It looks like only DRF 3.13 is incompatible with Django 4.2.

The way the matrix is currently set up in GitHub Actions and tox-gh-actions runs "every Python version against every Django version against every DRF version". This makes it harder to exclude a single environment (e.g. exclude Django 4.2 on DRF 3.13).

matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
django-version: ['3.2', '4.0', '4.1']
drf-version: ['3.10', '3.11', '3.12', '3.13', '3.14']

[gh-actions:env]
DJANGO=
3.2: dj32
4.0: dj40
4.1: dj41
DRF=
3.10: drf310
3.11: drf311
3.12: drf312
3.13: drf313
3.14: drf314

It is possible to be more specific/explicit using tox-gh-actions for example:

But I'm not sure what your preference here is.

@johnthagen johnthagen marked this pull request as draft May 31, 2023 12:38
@dpgraham4401
Copy link
Contributor

dpgraham4401 commented Jun 11, 2023

@johnthagen An option would be to configure the GH Actions test workflow to skip matrix configuration matching a certain criteria with the jobs.<job_id>.strategy.matrix.exclude keyword.

    matrix:
      python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
      django-version: ['3.2', '4.0', '4.1', '4.2']
      drf-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
      exclude:
        - django-version: '4.2'
          drf-version: '3.13'

I haven't tested, but should provide the desired outcome.

@johnthagen johnthagen marked this pull request as ready for review June 11, 2023 17:40
@johnthagen
Copy link
Contributor Author

Thanks @dpgraham4401! That was exactly what was needed. Implemented in d74835a.

@johnthagen
Copy link
Contributor Author

@Andrew-Chen-Wang this PR is now ready for review. Thanks.

Copy link
Member

@Andrew-Chen-Wang Andrew-Chen-Wang left a comment

Choose a reason for hiding this comment

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

Thank you everyone for helping out. This looks great!

@Andrew-Chen-Wang Andrew-Chen-Wang merged commit 9c8e70c into jazzband:master Jun 21, 2023
@johnthagen johnthagen deleted the django-4.2 branch June 21, 2023 13:27
mahdirahimi1999 pushed a commit to mahdirahimi1999/djangorestframework-simplejwt that referenced this pull request Jun 26, 2023
* Add support for Django 4.2

* Exclude DRF 3.13 & Django 4.2 CI combination
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update requirements section
3 participants