I already filled a feature request for recognizing derived modes through hideshow.
Until this feature request is handled you can use the following workaround in your init file:
(defun my-sage-initialize-hs ()
"Initialize `hs-special-mode-alist' for `sage-shell:sage-mode'.
Note: Function `python-mode' must be run at least once to make this work."
(unless (assoc 'sage-shell:sage-mode hs-special-modes-alist)
(add-to-list 'hs-special-modes-alist
(cons 'sage-shell:sage-mode
(cdr (assoc 'python-mode hs-special-modes-alist)))))
(hs-minor-mode))
(add-hook 'sage-shell:sage-mode-hook #'my-sage-initialize-hs)
The workaround links the settings for python-mode in hs-special-modes-alist to a new entry for sage-shell-mode.
Tested with Emacs 26.3, and sage-shell-mode-20191103.1040.
When the feature request is accepted and built into hideshow.el you do not need that workaround anymore since sage-shell-mode is really derived from python-mode.
sage-shell-mode?hide-showis a bit dumb in that regard. It does an(assoc major-mode hs-special-modes-alist)and not a(cl-assoc-if (lambda (mode) (derived-mode-p major-mode mode)) hs-special-modes-alist). So, if you want to adopt thepython-modehide-show blocks forsage-shell-mode, we need to copy the entries of thepython-modecons fromhs-special-modes-alistto a new entry withsage-shell-modeas car. (A copy is actually not necessary the right cdr link would do.) – Tobias Jan 30 '20 at 08:23