I have two suggestions, one, not using any non-default packages, very closely based on the definition of text-scale-adjust and one using hydra.
;; -*- lexical-binding: t -*-
;; the previous line needs to be the first in the given file.
(require 'python) ;; alternatively use an appropriate `use-package` declaration
(defun python-indent-adjust ...
This looks to me like an issue with emacs, but I have not yet nailed it down. At any rate, it looks like the problem is the code in http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/js.el?h=emacs-27.1#n4614 is running after all the other traditional packages (like editorconfig, etc) that I have used to set this value properly for different ...
There is emacs-tree-sitter, which is a package that uses tree-sitter a parser generator tool that can be use to get a AST of some supported languages.
Also emacs-tree-sitter support the option of get the AST of some languages so you can manipulate it and get some info, the documentation is interesting.
You could try to implement the LSP (language Server protocol) and use lsp-mode in conjunction with this. lsp-mode brings support for many languages already, but I'm not sure, if the LSP interface supports indentation.