Skip to content

chore(deps-dev): bump python group (8 updates) + fix mypy fallout - #3238

Merged
vpetersson merged 3 commits into
Screenly:masterfrom
vpetersson-bot:chore/python-deps-bump-mypy-fix
Aug 3, 2026
Merged

chore(deps-dev): bump python group (8 updates) + fix mypy fallout#3238
vpetersson merged 3 commits into
Screenly:masterfrom
vpetersson-bot:chore/python-deps-bump-mypy-fix

Conversation

@vpetersson-bot

Copy link
Copy Markdown
Contributor

Supersedes #3236 — same 8 dev-dependency bumps from the dependabot PR, plus the two mypy fixes that bump needs. Opened from a fork branch because vpetersson-bot only has pull access to this repo, so I could not push the fix onto the dependabot branch directly. Close #3236 in favour of this once merged (or cherry-pick the fix commit onto that branch — whichever you prefer).

The mypy failure on #3236

run-mypy failed with 5 errors, both caused by the djangorestframework-stubs 3.17.0 → 3.17.1 bump:

  1. types-psutil vanished. It was arriving transitively via djangorestframework-stubs, which dropped that edge in 3.17.1 — so the psutil imports in app/page_context.py and api/views/v2.py lost their stubs (Library stubs not installed for "psutil").
  2. request.data.get(...) union-attr (×3). The new stubs type Request.data as dict[str, Any] | list[Any], so .get() is rejected on the list branch in three upload/order endpoints in api/views/mixins.py.

Fix

  1. Pin types-psutil==7.2.2.20260408 as a direct dev dependency (in the dev-host group, alongside the other types-*), instead of relying on the transitive edge.
  2. Narrow with cast(dict[str, Any], request.data) at the three sites — these endpoints always receive a form/dict body. Using the sanctioned narrowing rather than a blanket # type: ignore.

Verified

  • mypy clean on all three previously-failing files (2.3.0 + django-stubs 6.0.7 + drf-stubs 3.17.1 + types-psutil).
  • uv lock regenerated (types-psutil restored to the lockfile).
  • ruff check + format clean; 464 api/template tests pass (the cast is a runtime no-op).

🤖 Generated with Claude Code

https://claude.ai/code/session_01HJ3ucEkn62cbgPoisAZ5LQ

dependabot Bot and others added 2 commits August 3, 2026 11:47
Bumps the python group with 8 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [djangorestframework-stubs](https://github.com/typeddjango/djangorestframework-stubs) | `3.17.0` | `3.17.1` |
| [ruff](https://github.com/astral-sh/ruff) | `0.16.0` | `0.16.1` |
| [types-gunicorn](https://github.com/python/typeshed) | `26.0.0.20260518` | `26.0.0.20260728` |
| [types-pytz](https://github.com/python/typeshed) | `2026.2.0.20260518` | `2026.3.1.20260727` |
| [pytz](https://github.com/stub42/pytz) | `2026.2` | `2026.3.post1` |
| [redis](https://github.com/redis/redis-py) | `8.0.1` | `8.1.0` |
| [sh](https://github.com/amoffat/sh) | `2.3.0` | `2.4.0` |
| [uvicorn[standard]](https://github.com/Kludex/uvicorn) | `0.51.0` | `0.52.0` |



Updates `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)

Updates `ruff` from 0.16.0 to 0.16.1
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.16.0...0.16.1)

Updates `types-gunicorn` from 26.0.0.20260518 to 26.0.0.20260728
- [Commits](https://github.com/python/typeshed/commits)

Updates `types-pytz` from 2026.2.0.20260518 to 2026.3.1.20260727
- [Commits](https://github.com/python/typeshed/commits)

Updates `pytz` from 2026.2 to 2026.3.post1
- [Release notes](https://github.com/stub42/pytz/releases)
- [Commits](stub42/pytz@release_2026.2...release_2026.3.post1)

Updates `redis` from 8.0.1 to 8.1.0
- [Release notes](https://github.com/redis/redis-py/releases)
- [Changelog](https://github.com/redis/redis-py/blob/master/CHANGES)
- [Commits](redis/redis-py@v8.0.1...v8.1.0)

Updates `sh` from 2.3.0 to 2.4.0
- [Release notes](https://github.com/amoffat/sh/releases)
- [Changelog](https://github.com/amoffat/sh/blob/develop/CHANGELOG.md)
- [Commits](amoffat/sh@2.3.0...2.4.0)

Updates `uvicorn[standard]` from 0.51.0 to 0.52.0
- [Release notes](https://github.com/Kludex/uvicorn/releases)
- [Changelog](https://github.com/Kludex/uvicorn/blob/main/docs/release-notes.md)
- [Commits](Kludex/uvicorn@0.51.0...0.52.0)

---
updated-dependencies:
- dependency-name: djangorestframework-stubs
  dependency-version: 3.17.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: python
- dependency-name: ruff
  dependency-version: 0.16.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: python
- dependency-name: types-gunicorn
  dependency-version: 26.0.0.20260728
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: python
- dependency-name: types-pytz
  dependency-version: 2026.3.1.20260727
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: python
- dependency-name: pytz
  dependency-version: 2026.3.post1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: python
- dependency-name: redis
  dependency-version: 8.1.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: python
- dependency-name: sh
  dependency-version: 2.4.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: python
- dependency-name: uvicorn[standard]
  dependency-version: 0.52.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: python
...

Signed-off-by: dependabot[bot] <[email protected]>
…s 3.17.1

The djangorestframework-stubs 3.17.0 → 3.17.1 bump in this PR broke mypy
two ways:

1. It dropped its transitive types-psutil, so the psutil imports in
   page_context.py / api/views/v2.py lost their stubs
   ("Library stubs not installed for psutil"). Pin types-psutil as a
   direct dev dependency instead of relying on the transitive edge.

2. Its Request.data is now typed dict[str, Any] | list[Any], so
   request.data.get(...) fails union-attr in three upload/order
   endpoints. These endpoints always receive a form/dict body, so
   narrow with cast(dict[str, Any], request.data) — the sanctioned
   narrowing, not a blanket ignore.

mypy clean on the three files; 464 api/template tests pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HJ3ucEkn62cbgPoisAZ5LQ
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@11de817). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/anthias_server/api/views/mixins.py 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3238   +/-   ##
=========================================
  Coverage          ?   90.82%           
=========================================
  Files             ?       76           
  Lines             ?     8361           
  Branches          ?      885           
=========================================
  Hits              ?     7594           
  Misses            ?      549           
  Partials          ?      218           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Python dev dependency set (matching the superseded Dependabot bump) and adjusts server code to keep mypy passing after upstream typing changes in djangorestframework-stubs.

Changes:

  • Bump 8 Python (dev and runtime) dependencies, including djangorestframework-stubs, ruff, redis, sh, and uvicorn.
  • Add types-psutil as an explicit dev dependency to restore psutil stubs after it stopped arriving transitively.
  • Adjust a few API endpoints to satisfy the updated DRF typing for Request.data (now dict | list).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
uv.lock Regenerates the lockfile for the dev dependency bumps and adds types-psutil to the resolved sets.
src/anthias_server/api/views/mixins.py Adds cast(...)-based narrowing for request.data at three endpoints to address new DRF stub unions.
pyproject.toml Updates pinned versions and adds types-psutil to the dev-host group (pulled into the CI mypy group via include-group).
Suppressed comments (2)

src/anthias_server/api/views/mixins.py:293

  • This endpoint relies on request.data.get(...), but request.data can be a list for JSON bulk payloads per DRF stubs. The current cast(dict[str, Any], request.data) won’t stop a runtime AttributeError in that case. Explicitly reject list payloads before calling .get() to return a 400 rather than a 500.
        try:
            data = cast(dict[str, Any], request.data)
            file_upload = data.get('file_upload')

src/anthias_server/api/views/mixins.py:502

  • request.data is typed as dict | list; casting it to dict doesn’t prevent a runtime failure if a client sends a list payload. Reject list payloads up-front so .get('ids', ...) is safe and the API responds with a 400 on invalid body types.
        data = cast(dict[str, Any], request.data)
        asset_ids = data.get('ids', '').split(',')

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/anthias_server/api/views/mixins.py Outdated
Copilot review on the deps-bump PR: cast(dict, request.data) only
satisfied mypy — a JSON list body (DRF sets request.data to a list)
would still hit .get() and raise AttributeError, i.e. a 500. Replace
the cast with an isinstance(data, dict) guard at all three upload/order
endpoints so a non-dict body falls through to the existing 400 (and
mypy still narrows via the local). Add a regression test that a list
body to the file-asset endpoint returns 400, not 500.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HJ3ucEkn62cbgPoisAZ5LQ
@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

@vpetersson
vpetersson merged commit 2f4bb1a into Screenly:master Aug 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants