Skip to content

mypy: nullable uuid passed unnarrowed into RestoreVersionCommand calls in new versioning tests #44788

Description

@sadpandajoe

Problem

tests/unit_tests/versioning/test_runtime_capture.py and tests/unit_tests/versioning/test_capture_gap_restore.py fail nightly full-repo mypy on master. First failing run: https://github.com/apache/superset/actions/runs/36530938046/job/109284247292 ("pre-commit (next)", commit ca3d356).

Root cause

UUIDMixin.uuid (superset/models/helpers.py:740-742) is a nullable column, so mypy infers SqlaTable.uuid / Dashboard.uuid as UUID | None. BaseRestoreVersionCommand.__init__ (superset/commands/version_restore.py:78) requires a non-optional UUID. PR #44514 added the two test files and passed .uuid straight into RestoreDatasetVersionCommand/RestoreDashboardVersionCommand without narrowing (e.g. test_runtime_capture.py:229, test_capture_gap_restore.py:186,236,257,306,311,416,488,608,609,720,753,786), and test_runtime_capture.py:253 assigns the nullable value into a : UUID-annotated variable, which fails at the assignment itself.

Steps to reproduce

pre-commit run mypy --files tests/unit_tests/versioning/test_runtime_capture.py tests/unit_tests/versioning/test_capture_gap_restore.py

run against a commit on master before the fix, or open the mypy step output in the job log linked above.

(Found via automated investigation — Agor.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai:fix-mastergenerated by AI to fix master branch

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions