   :config
   (setf flycheck-pylintrc `("pylintrc" ".pylintrc" "pyproject.toml" "setup.cfg"
                             ,(or (getenv "PYLINTRC")
-                                 (expand-file-name "~/.config/pylintrc"))
+                                 (expand-file-name
+                                  (concat (or (and (getenv "XDG_CONFIG_HOME")
+                                                   (file-name-as-directory (getenv "XDG_CONFIG_HOME")))
+                                              "~/.config/")
+                                          "pylintrc")))
                             "/etc/pylintrc"))
 
   (setf flycheck-flake8rc `(".flake8" "setup.cfg" "tox.ini"
-                            ,(expand-file-name "~/.config/flake8")))
+                            ,(expand-file-name
+                              (concat
+                               (or (and (getenv "XDG_CONFIG_HOME")
+                                        (file-name-as-directory (getenv "XDG_CONFIG_HOME")))
+                                   "~/.config/")
+                               "flake8"))))
 
   (setf flycheck-python-mypy-config `("mypy.ini" ".mypy.ini" "pyproject.toml" "setup.cfg"
                                       ,(concat (expand-file-name

  (when (and (buffer-file-name)
             (derived-mode-p 'python-mode))
    (let* ((buf-file (buffer-file-name))
           (root (and (functionp 'projectile-acquire-root)
                      (projectile-acquire-root (file-name-directory buf-file)))))

      (when (and root
                 (not (seq-some (lambda (buf)

                 t))
      (python-isort-on-save-mode 1))))

(defun python-poetry-virtualenv-path ()
  (with-temp-buffer
    (if (condition-case err
            (zerop (call-process "poetry" nil t nil "env" "info" "-p"))
          (error (minibuffer-message "%s" (error-message-string err)) nil))
        (string-trim (buffer-string))
      nil)))

(add-hook 'python-mode-hook
          (lambda ()
            ;; Set `python-shell-interpreter'
            (when (python-use-poetry-p)
              (when-let ((virtualenv-root (python-poetry-virtualenv-path)))
                (make-local-variable 'python-shell-interpreter)
                (make-local-variable 'python-shell-virtualenv-root)
                (setf python-shell-interpreter (concat virtualenv-root "/bin/python")
                      python-shell-virtualenv-root virtualenv-root)))

            (with-eval-after-load 'dap-python
              (setf dap-python-executable python-shell-interpreter))
