mirror of
https://github.com/apache/superset.git
synced 2026-08-05 13:32:41 +00:00
Two coupled clean-code review fixes: (1) Rename ``VersionDAO._find_active_entity_by_uuid`` → ``find_active_by_uuid``. The leading-underscore + three ``# pylint: disable=protected-access`` suppressions in the restore commands were the smell of a wrongly-private API. The method is a perfectly reasonable public DAO operation; dropping the underscore removes the suppressions. (2) Collapse ``RestoreChartVersionCommand``, ``RestoreDashboardVersionCommand``, ``RestoreDatasetVersionCommand`` onto a shared ``BaseRestoreVersionCommand`` (``superset/commands/version_restore.py``). The three classes were textbook copy-paste — identical except for the model class and three exception types. Each subclass now declares ``model_cls`` + ``not_found_exc`` + ``forbidden_exc`` and overrides ``run()`` with one ``@transaction(reraise=<failed_exc>)``-decorated line delegating to ``self._do_restore()``. ~80 lines per file → ~45 lines per file; one shared workflow instead of three drift sources. The api.py imports of ``RestoreChartVersionCommand`` / ``RestoreDashboardVersionCommand`` / ``RestoreDatasetVersionCommand`` are unchanged — public class names preserved.