               python-pre-commit-config-cache)
         content))))
 
+(defun python-poetry-config-path ()
+  (when-let ((dir (locate-dominating-file default-directory "pyproject.toml")))
+    (concat dir "pyproject.toml")))
+
 (defun python-use-poetry-p ()
   (and (python-poetry-config-path)
+       (with-temp-buffer
+         (insert-file-contents (python-poetry-config-path))
+         (goto-char (point-min))
+         (search-forward "[tool.poetry]" nil t nil))
        (executable-find "poetry")))
 
 (defun python-use-pre-commit-p (requirements)
   (and (python-pre-commit-config-path)
        (or (executable-find "pre-commit")
            (member "pre-commit" requirements))))
+
+(defun python-project-requirements-from-file (&optional file-path)
+  (when-let ((requirements-file
+              (or file-path
+                  (concat
+                   (locate-dominating-file default-directory "requirements.txt")
+                   "requirements.txt"))))
+    (with-temp-buffer
+      (insert-file-contents requirements-file)
+      (goto-char (point-min))
+      (string-lines (string-trim (buffer-string))))))
+
+(defun python-parse-requirement-spec (req)
+  (save-match-data
+    (if (not (null (string-match "^-r +\\(.+\\)$" req)))
+        (mapcar 'python-parse-requirement-spec
+                (python-project-requirements-from-file
+                 (match-string-no-properties 1 req)))
+      (let* ((requirement-spec (split-string req ";"))
+             (package-version-spec (string-trim (car requirement-spec)))
+             (python-version-spec (string-trim (cadr requirement-spec))))
+        (car (split-string package-version-spec "=="))))))
 
 (defvar python-project-requirements-cache nil)
 (defun python-project-requirements ()

          (lambda ()
            (use-package python-docstring
              :delight
              :config (python-docstring-mode))

            (when (python-use-poetry-p)
              (make-local-variable 'python-shell-interpreter)

              (add-to-list 'company-transformers 'company-sort-prefer-same-case-prefix t))))

;; Linting
(defun python-pre-commit-config-path ()
  (when-let ((dir (locate-dominating-file default-directory ".pre-commit-config.yaml")))
    (concat dir ".pre-commit-config.yaml")))

(defvar python-pre-commit-config-cache nil)
(defun python-pre-commit-config ()
