Skip to content

Commit 5f96d9a

Browse files
Bump djangorestframework-stubs from 3.17.0 to 3.17.1 (#2211)
* Bump djangorestframework-stubs from 3.17.0 to 3.17.1 Bumps [djangorestframework-stubs](https://github.com/typeddjango/djangorestframework-stubs) from 3.17.0 to 3.17.1. - [Release notes](https://github.com/typeddjango/djangorestframework-stubs/releases) - [Commits](typeddjango/djangorestframework-stubs@3.17.0...3.17.1) --- updated-dependencies: - dependency-name: djangorestframework-stubs dependency-version: 3.17.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Fix typing errors with django-stubs 6.0.7 * Support django field signatures across stub versions * Fix Codecov coverage for django stubs update * Bump django-stubs to 6.0.7 to satisfy djangorestframework-stubs 3.17.1's constraint djangorestframework-stubs 3.17.1 requires django-stubs>=6.0.7, causing pip's ResolutionImpossible against the django-stubs==6.0.6 pin still in requirements/local.txt. The three preceding commits are the same django-stubs 6.0.7 mypy fixes already landed on the parallel django-stubs bump PR. * Fix mypy union-attr error from djangorestframework-stubs 3.17.1's widened request.data type 3.17.1 widens request.data to dict[str, Any] | list[Any] to match DRF's real behavior for bulk JSON array payloads, which broke .get() on the worker-uploads endpoint's metadata-size check. That endpoint only accepts MultiPartParser, so request.data is always dict-like at runtime; narrowed with isinstance rather than suppressing the check. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JSv4 <scrudato@umich.edu>
1 parent b1198e1 commit 5f96d9a

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- `opencontractserver/worker_uploads/views.py:94` — `djangorestframework-stubs`
2+
3.17.1 widened `request.data`'s type to `dict[str, Any] | list[Any]`
3+
(matching DRF's real behavior for bulk JSON array payloads), which surfaced
4+
a `union-attr` mypy error on `request.data.get(...)`. This view only accepts
5+
`MultiPartParser`, so `request.data` is always dict-like at runtime; added
6+
an `isinstance` narrowing consistent with the existing dict check two lines
7+
below rather than suppressing the type error.

‎opencontractserver/worker_uploads/views.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,17 @@ def post(self, request: Request) -> Response:
9191
# Enforce metadata size limit
9292
max_metadata_size = settings.MAX_WORKER_METADATA_SIZE_BYTES
9393
if max_metadata_size:
94-
raw_metadata = request.data.get("metadata", "")
94+
# request.data is dict-like here in practice: this view only
95+
# accepts MultiPartParser (see parser_classes above), never
96+
# JSONParser, so DRF's request.data | list[Any] union (list is
97+
# DRF's shape for a bulk JSON array body) never actually resolves
98+
# to a list on this endpoint.
99+
request_data = request.data
100+
raw_metadata = (
101+
request_data.get("metadata", "")
102+
if isinstance(request_data, dict)
103+
else ""
104+
)
95105
if isinstance(raw_metadata, dict):
96106
metadata_size = len(json.dumps(raw_metadata).encode())
97107
else:

‎requirements/local.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pytest==9.1.1 # https://github.com/pytest-dev/pytest
1212
pytest-cov==7.1.0 # https://github.com/pytest-dev/pytest-cov
1313
pytest-xdist==3.8.0 # https://github.com/pytest-dev/pytest-xdist (parallel test execution)
1414
pytest-timeout==2.4.0 # https://github.com/pytest-dev/pytest-timeout (per-test hang guard in CI)
15-
djangorestframework-stubs==3.17.0 # https://github.com/typeddjango/djangorestframework-stubs
15+
djangorestframework-stubs==3.17.1 # https://github.com/typeddjango/djangorestframework-stubs
1616
responses==0.26.2 # https://github.com/getsentry/responses
1717
# Keep at >=8.2.0. Earlier releases' aiohttp stub subclasses
1818
# aiohttp.streams.AsyncStreamReaderMixin at import time, a symbol aiohttp 3.14

0 commit comments

Comments
 (0)