Skip to content

Commit b25028a

Browse files
authored
Add support for Python 3.13 (encode#9527)
* Add support for Python 3.13 * Fix extracting tox env with -dev Python versions * Fix view description inspection in Python 3.13 Python 3.13 introduced docstrings for None: python/cpython#117813 In Python 3.12, this is an empty string: ``` ➜ python3.12 Python 3.12.6 (main, Sep 10 2024, 19:06:17) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> d = None >>> d.__doc__ >>> ``` In Python 3.13, it's no longer empty: ``` ➜ python3.13 Python 3.13.0rc2+ (heads/3.13:660baa1, Sep 10 2024, 18:57:50) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> d = None >>> d.__doc__ 'The type of the None singleton.' >>> ``` Adding a check in the inspector that get the view description out the view function docstring to catch this edge case.
1 parent a59aa2d commit b25028a

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- '3.10'
2020
- '3.11'
2121
- '3.12'
22+
- '3.13-dev'
2223

2324
steps:
2425
- uses: actions/checkout@v4
@@ -36,7 +37,7 @@ jobs:
3637
run: python -m pip install --upgrade codecov tox
3738

3839
- name: Run tox targets for ${{ matrix.python-version }}
39-
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .)
40+
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d . | cut -f 1 -d '-')
4041

4142
- name: Run extra tox targets
4243
if: ${{ matrix.python-version == '3.9' }}

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ continued development by **[signing up for a paid plan][funding]**.
8888
REST framework requires the following:
8989

9090
* Django (4.2, 5.0, 5.1)
91-
* Python (3.8, 3.9, 3.10, 3.11, 3.12)
91+
* Python (3.8, 3.9, 3.10, 3.11, 3.12, 3.13)
9292

9393
We **highly recommend** and only officially support the latest patch release of
9494
each Python and Django series.

rest_framework/schemas/inspectors.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ def get_description(self, path, method):
7979
view = self.view
8080

8181
method_name = getattr(view, 'action', method.lower())
82-
method_docstring = getattr(view, method_name, None).__doc__
83-
if method_docstring:
82+
method_func = getattr(view, method_name, None)
83+
method_docstring = method_func.__doc__
84+
if method_func and method_docstring:
8485
# An explicit docstring on the method or action.
8586
return self._get_description_section(view, method.lower(), formatting.dedent(smart_str(method_docstring)))
8687
else:

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def get_version(package):
102102
'Programming Language :: Python :: 3.10',
103103
'Programming Language :: Python :: 3.11',
104104
'Programming Language :: Python :: 3.12',
105+
'Programming Language :: Python :: 3.13',
105106
'Programming Language :: Python :: 3 :: Only',
106107
'Topic :: Internet :: WWW/HTTP',
107108
],

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ envlist =
44
{py310}-{django42,django50,django51,djangomain}
55
{py311}-{django42,django50,django51,djangomain}
66
{py312}-{django42,django50,django51,djangomain}
7+
{py313}-{django51,djangomain}
78
base
89
dist
910
docs

0 commit comments

Comments
 (0)