sadpandajoe opened a new pull request, #45616:
URL: https://github.com/apache/superset/pull/45616

   ### SUMMARY
   
   The nightly `pre-commit checks` run on master fails `mypy (main)` with three 
errors in two files, both added by #44347 (77ebc0e5, "fix(chart): keep 
dataset_uuid in exports when the dataset is deleted"):
   
       superset/commands/export/assets.py:157: error: Argument 1 to "set" has 
incompatible type "list[int | str]"; expected "Iterable[int | None]"  [arg-type]
       tests/unit_tests/commands/chart/export_test.py:403: error: Item "UUID" 
of "UUID | None" has no attribute "in_"  [union-attr]
       tests/unit_tests/commands/chart/export_test.py:403: error: Item "None" 
of "UUID | None" has no attribute "in_"  [union-attr]
   
   These only show up when mypy checks the whole tree. With `--all-files`, 
superset-core's sources are part of the run, so `SqlaTable` picks up 
`CoreDataset`'s plain `id: int` and `uuid: UUID | None` annotations. In the 
per-PR run, which only checks changed files, superset_core is not resolved and 
both attributes are `Any`, so #44347 passed its own checks. Nothing is wrong at 
runtime: `dataset_ids` holds the integer ids from `find_all()`, and 
`SqlaTable.uuid` is a column.
   
   The fix:
   
   - `assets.py`: `referenced - set(dataset_ids)` becomes 
`referenced.difference(dataset_ids)`. Same result, and `set.difference()` 
accepts any iterable, so it type-checks in both modes.
   - `export_test.py`: `SqlaTable.uuid.in_(...)` gets `# type: 
ignore[union-attr]`, the same as the existing `SqlaTable.uuid.in_()` / 
`Slice.uuid.in_()` sites.
   - `pyproject.toml`: adds the test module to the existing 
`warn_unused_ignores = false` override for this case. Without it, a per-PR run 
that touches only this file reports the ignore as unused.
   
   ### TESTING INSTRUCTIONS
   
   1. On master, run `prek run mypy --all-files` (or `pre-commit run mypy 
--all-files`) and see the three errors above.
   2. On this branch, run the same command: `mypy (main)` passes.
   3. Run `prek run mypy --files pyproject.toml 
superset/commands/export/assets.py 
tests/unit_tests/commands/chart/export_test.py` to check that the per-PR, 
changed-files-only run also passes.
   4. Optionally, export all assets from Settings > Import/Export with a chart 
whose dataset is in the trash, and check the bundle still includes that 
dataset. This change does not alter that behaviour.
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: Fixes #45615
   - [ ] 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
   
   Notes:
   - An inline `# type: ignore[union-attr,unused-ignore]` on 
`export_test.py:403` would avoid the pyproject override (the repo does this in 
`superset/daos/chart.py:80` and `superset/daos/dataset.py:104`). This PR 
follows the existing pyproject convention for `SqlaTable.uuid.in_()` instead.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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]

Reply via email to