sadpandajoe opened a new pull request, #44789:
URL: https://github.com/apache/superset/pull/44789
### SUMMARY
PR #44514 ("feat(versioning): gate history APIs and runtime capture", commit
77295721ff96) added tests/unit_tests/versioning/test_runtime_capture.py and
test_capture_gap_restore.py. Both files pass Dashboard.uuid / SqlaTable.uuid —
typed `UUID | None` via UUIDMixin's nullable column
(superset/models/helpers.py:740-742) — directly into
RestoreDashboardVersionCommand / RestoreDatasetVersionCommand, whose
constructor requires a non-optional UUID
(superset/commands/version_restore.py:78), without narrowing away None first.
One site (test_runtime_capture.py:253) additionally assigned the nullable value
into a variable with an explicit `: UUID` annotation, which fails at the
assignment itself. This is the same defect class already fixed three times in
this codebase (#44394, #44424, #44648) via an `x = obj.uuid; assert x is not
None` idiom; #44514 didn't reuse it, and this one site independently
reintroduced the exact anti-pattern (explicit `: UUID` annotation defeating
assert-narrow
ing) that caused the #44648 regression.
This PR extracts each of the 14 flagged `.uuid` reads into an unannotated
local, asserts it is not None, and passes the narrowed local into the restore
command. Type-checking only — no behavior change.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
### TESTING INSTRUCTIONS
Run `pre-commit run mypy --files
tests/unit_tests/versioning/test_runtime_capture.py
tests/unit_tests/versioning/test_capture_gap_restore.py` (or `mypy
--check-untyped-defs` against those two files) and confirm no
`arg-type`/`assignment` errors remain on the previously-flagged lines. Run
`pytest tests/unit_tests/versioning/test_runtime_capture.py
tests/unit_tests/versioning/test_capture_gap_restore.py` and confirm all tests
still pass — the new asserts never fire under normal test execution since
`.uuid` is always populated after `capture_session.commit()`.
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #44788
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]