 (require 'cl-lib)
 (require 'subr-x)
 (require 'let-alist)
+(require 'rx)
 
 (set-locale-environment "UTF-8")
 (custom-autoload 'package-selected-packages "package")

               (make-local-variable flycheck-executable-variable)
               (setf (symbol-value flycheck-executable-variable)
                     (with-temp-buffer
                       (if (zerop
                            (condition-case err
                                (call-process "poetry" nil t nil "run" "which" executable-name)
                              (error (message "%s" (error-message-string err)) nil)))
                           (string-trim (buffer-string))
                         nil))))
              ((executable-find executable-name)
               (make-local-variable flycheck-executable-variable)
               (setf (symbol-value flycheck-executable-variable) executable-name)))))

    (if (equal (alist-get 'modification-time cache-value) modification-time)
        (alist-get 'content cache-value)
      (let ((content
             (condition-case err
                 (with-temp-buffer
                   (funcall 'call-process "dasel" nil t nil "select" "-f" (python-pre-commit-config-path) "-w" "json")
                   (goto-char (point-min))
                   (json-parse-buffer :object-type 'alist :array-type 'list))
               (error (error-message-string err) nil))))
        (assoc-delete-all config-path python-pre-commit-config-cache)
        (when content
          (push `(,config-path . ((modification-time . ,modification-time)
                                  (content . ,content)))
                python-pre-commit-config-cache))
        content))))

(defun python-pyproject-path ()
  (when-let ((dir (locate-dominating-file default-directory "pyproject.toml")))
    (expand-file-name (concat dir "pyproject.toml"))))

(defun python-use-poetry-p ()
  (and (python-pyproject-path)
