From 8b66b7429e4af1fcd81f37b02c457dbf47dd47b9 Mon Sep 17 00:00:00 2001 From: Pravin Kamble Date: Sun, 13 Sep 2026 19:25:23 +0530 Subject: [PATCH 1/2] Update pre-commit hooks --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 779dcf67eb..54000d4836 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: - id: check-symlinks - id: check-toml - repo: https://github.com/PyCQA/isort - rev: 7.0.0 + rev: 9.0.1 hooks: - id: isort - repo: https://github.com/PyCQA/flake8 @@ -28,7 +28,7 @@ repos: - black==26.1.0 - repo: https://github.com/codespell-project/codespell # Configuration for codespell is in pyproject.toml - rev: v2.4.1 + rev: v2.4.3 hooks: - id: codespell additional_dependencies: @@ -40,10 +40,10 @@ repos: - id: pyupgrade args: ["--py310-plus", "--keep-percent-format"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: v2.11.1 + rev: v2.29.4 hooks: - id: pyproject-fmt - repo: https://github.com/adamchainz/django-upgrade - rev: 1.24.0 + rev: 1.32.0 hooks: - id: django-upgrade From dce5578ae43d41865449a5cbb19a40e50652c54c Mon Sep 17 00:00:00 2001 From: Pravin Kamble Date: Sun, 13 Sep 2026 19:33:31 +0530 Subject: [PATCH 2/2] Fixed formatting --- pyproject.toml | 59 +++++++++++++++++---------------------- rest_framework/parsers.py | 3 +- tests/test_authtoken.py | 3 +- 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f59dbb02a9..80fcea7dd5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,6 @@ test = [ "pytest==9.*", "pytest-cov==7.*", "pytest-django>=4.5.2,<5", - ] docs = [ # MkDocs to build our documentation. @@ -57,6 +56,10 @@ docs = [ # pylinkvalidator to check for broken links in documentation. "pylinkvalidator==0.3", ] +django52 = [ "django>=5.2,<6.0" ] +django60 = [ "django>=6.0,<6.1" ] +django61 = [ "django>=6.1,<6.2" ] +djangomain = [ "django @ https://github.com/django/django/archive/main.tar.gz" ] optional = [ # Optional packages which may be used with REST framework. "django-filter", @@ -70,33 +73,23 @@ optional = [ "requests", "uritemplate", ] -django52 = [ "django>=5.2,<6.0" ] -django60 = [ "django>=6.0,<6.1" ] -django61 = [ "django>=6.1,<6.2" ] -djangomain = [ "django @ https://github.com/django/django/archive/main.tar.gz" ] [tool.setuptools] - -[tool.setuptools.dynamic] -version = { attr = "rest_framework.__version__" } - -[tool.setuptools.packages.find] -include = [ "rest_framework*" ] - -[tool.setuptools.package-data] -"rest_framework" = [ - "templates/**/*", - "static/**/*", +packages.find.include = [ "rest_framework*" ] +package-data.rest_framework = [ "locale/**/*.mo", + "static/**/*", + "templates/**/*", ] +dynamic.version = { attr = "rest_framework.__version__" } [tool.isort] -skip = [ ".tox" ] atomic = true multi_line_output = 5 extra_standard_library = [ "types" ] -known_third_party = [ "pytest", "_pytest", "django", "uritemplate" ] +known_third_party = [ "_pytest", "django", "pytest", "uritemplate" ] known_first_party = [ "rest_framework", "tests" ] +skip = [ ".tox" ] [tool.flake8] extend-ignore = [ "E501", "W503", "W504", "B" ] @@ -104,15 +97,15 @@ extend-select = [ "B006" ] banned-modules = "json = use from rest_framework.utils import json!" [tool.codespell] -# Ref: https://github.com/codespell-project/codespell#using-a-config-file -skip = "*/kickstarter-announcement.md,*.js,*.map,*.po,*.css,locale" +builtin = "clear,rare,code,names,en-GB_to_en-US" ignore-words = "codespell-ignore-words.txt" ignore-words-list = "commitish" -builtin = "clear,rare,code,names,en-GB_to_en-US" +# Ref: https://github.com/codespell-project/codespell#using-a-config-file +skip = "*/kickstarter-announcement.md,*.js,*.map,*.po,*.css,locale" [tool.pyproject-fmt] -max_supported_python = "3.14" keep_full_version = true +max_supported_python = "3.14" [tool.pytest] addopts = [ @@ -121,23 +114,21 @@ addopts = [ "-ra", "--no-migrations", ] -testpaths = [ "tests" ] -markers = [ - "requires_postgres: marks tests as requiring a PostgreSQL database backend", -] filterwarnings = [ "ignore:'cgi' is deprecated:DeprecationWarning", ] +markers = [ + "requires_postgres: marks tests as requiring a PostgreSQL database backend", +] +testpaths = [ "tests" ] -[tool.coverage.run] +[tool.coverage] # NOTE: source is ignored with pytest-cov (but uses the same). -source = [ "." ] -include = [ "rest_framework/*", "tests/*" ] -branch = true - -[tool.coverage.report] -include = [ "rest_framework/*", "tests/*" ] -exclude_lines = [ +run.source = [ "." ] +run.include = [ "rest_framework/*", "tests/*" ] +run.branch = true +report.include = [ "rest_framework/*", "tests/*" ] +report.exclude_lines = [ "pragma: no cover", "raise NotImplementedError", ] diff --git a/rest_framework/parsers.py b/rest_framework/parsers.py index 0e8e4bcb8d..8d6322fd49 100644 --- a/rest_framework/parsers.py +++ b/rest_framework/parsers.py @@ -12,8 +12,9 @@ from django.core.files.uploadhandler import StopFutureHandlers from django.http import QueryDict from django.http.multipartparser import ChunkIter -from django.http.multipartparser import \ +from django.http.multipartparser import ( MultiPartParser as DjangoMultiPartParser +) from django.http.multipartparser import MultiPartParserError from django.utils.http import parse_header_parameters diff --git a/tests/test_authtoken.py b/tests/test_authtoken.py index 520bd29215..40e5445893 100644 --- a/tests/test_authtoken.py +++ b/tests/test_authtoken.py @@ -10,8 +10,9 @@ from django.test import TestCase, modify_settings from rest_framework.authtoken.admin import TokenAdmin -from rest_framework.authtoken.management.commands.drf_create_token import \ +from rest_framework.authtoken.management.commands.drf_create_token import ( Command as AuthTokenCommand +) from rest_framework.authtoken.models import Token, TokenProxy from rest_framework.authtoken.serializers import AuthTokenSerializer from rest_framework.exceptions import ValidationError