doomemacs/modules/lang/python
Henrik Lissner 3ce5d96e0a
bump: :lang
ShuguangSun/ess-view-data@5ec1c7206f -> ShuguangSun/ess-view-data@7dcbd23d4c
agda/agda@0d52fa2217 -> agda/agda@bb9e13d970
ardumont/markdown-toc@d3324cb6bc -> ardumont/markdown-toc@29e5c0f33e
atomontage/xterm-color@ce82e87ea3 -> atomontage/xterm-color@86fab1d247
babashka/neil@0b7373dd1b -> babashka/neil@8d5ccdbd81
clojure-emacs/cider@fb7aa88812 -> clojure-emacs/cider@15bd3b0265
clojure-emacs/clojure-mode@28dc02114a -> clojure-emacs/clojure-mode@4679222109
crystal-lang-tools/emacs-crystal-mode@d913fea6f0 -> crystal-lang-tools/emacs-crystal-mode@559e1d8ff9
davazp/graphql-mode@ee49531935 -> davazp/graphql-mode@ef757c6ce2
emacs-ess/ESS@7b9123669c -> emacs-ess/ESS@f8c464dc1b
emacs-geiser/gauche@9eb8b35f0c -> emacs-geiser/gauche@b8197c6288
emacs-geiser/geiser@43b9a034aa -> emacs-geiser/geiser@8842104d15
emacs-lsp/lsp-treemacs@3e5550f278 -> emacs-lsp/lsp-treemacs@49df7292c5
emacs-php/composer.el@eba6b953a4 -> emacs-php/composer.el@8cb5704edd
emacs-straight/auctex@a6f4741c22 -> emacs-straight/auctex@077874d25a
emacsmirror/cmake-mode@b08b5d9045 -> emacsmirror/cmake-mode@25340a7d12
emacsorphanage/dart-mode@9fbf703e1f -> emacsorphanage/dart-mode@773e9ebc74
emacsorphanage/ox-pandoc@5766c70b6d -> emacsorphanage/ox-pandoc@1caeb56a4b
emacsorphanage/restclient@426507f8f7 -> emacsorphanage/restclient@1800a4e367
erlang/otp@e281016db9 -> erlang/otp@2b2b39797f
fxbois/web-mode@1eb0abb1a9 -> fxbois/web-mode@1e7694aee8
gcv/julia-snail@7b50882f5a -> gcv/julia-snail@5a7e2d479c
godotengine/emacs-gdscript-mode@79739fc80f -> godotengine/emacs-gdscript-mode@248b73b1bd
greghendershott/racket-mode@d98852ef6d -> greghendershott/racket-mode@150b057953
hhvm/hack-mode@0addbff8b6 -> hhvm/hack-mode@86a981bd7b
https://codeberg.org/pranshu/haskell-ts-mode@b7db74c7fe96 -> https://codeberg.org/pranshu/haskell-ts-mode@bf143ee8382f
joaotavora/sly@6a303bae74 -> joaotavora/sly@b01993cf1d
ledger/ledger-mode@1cee636788 -> ledger/ledger-mode@9ab399186f
magit/orgit-forge@15f8e91083 -> magit/orgit-forge@c2116b8701 (v1.1.1)
magit/orgit@e0b3fca9f3 -> magit/orgit@24c8fe48c4 (v2.1.1)
mekeor/nael@101726eb47 -> mekeor/nael@9711443449
minad/org-modern@55b5bbeb1e -> minad/org-modern@9bbc44cc7e
nonsequitur/inf-ruby@b8076aad10 -> nonsequitur/inf-ruby@274398a242
ocaml/dune@a40c461736 -> ocaml/dune@14df34d30d
ocaml/merlin@ecfbed3976 -> ocaml/merlin@a0b096c243
oer/org-re-reveal@72c2463782 -> oer/org-re-reveal@8245facfdc
org-noter/org-noter@aafa08a49c -> org-noter/org-noter@81765d267e
org-roam/org-roam@b2634a17f8 -> org-roam/org-roam@c72702cf27
polymode/polymode@25ba9463a4 -> polymode/polymode@14b1fd8d2a
rust-lang/rust-mode@2d31814676 -> rust-lang/rust-mode@ae161dca23
wbolster/emacs-python-pytest@ed2ecee09d -> wbolster/emacs-python-pytest@78b5ea1d19
weijiangan/flycheck-golangci-lint@38cc30eb8b -> weijiangan/flycheck-golangci-lint@f7e36e19d6

Close: #8624
2026-01-18 03:13:00 -05:00
..
autoload fix(python): define +python-uv-mode-set-auto-h 2025-12-31 08:08:27 -05:00
.doommodule feat: add .doommodule files 2024-09-14 20:47:39 -04:00
config.el feat(python): add uv support 2025-12-30 22:58:47 -05:00
doctor.el feat(python): add uv support 2025-12-30 22:58:47 -05:00
packages.el bump: :lang 2026-01-18 03:13:00 -05:00
README.org feat(python): add uv support 2025-12-30 22:58:47 -05:00

:lang python

Description   unfold

This module adds Python support to Doom Emacs.

Module flags

+conda
Enable python virtual environment support via Conda.
+cython
Enable support for Cython files support.
+lsp
Enable LSP support for python-mode and python-ts-mode. Requires doom-module::tools lsp and an LSP server (e.g. ty (recommended), pyright, basedpyright, jedi, ruff).
+poetry
Enable Python packaging, dependency management, and virtual environment support via Poetry.
+pyenv
Enable Python virtual environment support via pyenv. Cannot be used together with doom-module:+uv.
+pyright
Add support for the pyright LSP server (requires doom-module:+lsp).
+tree-sitter
Leverages tree-sitter for better syntax highlighting and structural text editing. Requires doom-module::tools tree-sitter. Support is much improved on Emacs 30 and newer.
+uv
Enable Python virtual environment support via uv. Cannot be used together with doom-module:+pyenv.

Hacks

No hacks documented for this module.

TODO Changelog

This module does not have a changelog yet.

Installation

Enable this module in your doom! block.

This module has no hard requirements, but softly depends on:

  • For this module's supported test runners:

    • $ pip install pytest
    • $ pip install nose
  • The doom-module::editor format module uses Black for python files: $ pip install black
  • doom-package:pyimport requires Python's module pyflakes: $ pip install pyflakes
  • doom-package:py-isort requires isort to be installed: pip install isort
  • Python virtual environments install instructions at:

  • cython requires Cython

Language Server Protocol Support

For LSP support the doom-module::tools lsp module must be enabled, along with this module's doom-module:+lsp flag. It supports anything that lsp-mode and Eglot support. ty is recommended. Some can be installed from within Emacs using M-x lsp-install-server, others are available through OS package managers or pip. E.g.

ty
$ pip install ty
basedpyright
$ pip install basedpyright
pyright
$ pip install pyright or $ npm i -g pyright.

If you have multiple LSP servers installed and on your $PATH, lsp-mode and eglot prioritizes which will be used depending on the client's :priority (in lsp-mode) or their order in eglot-server-programs.

To prioritize ty:

;;; add to $DOOMDIR/config.el

;; for eglot users
(after! python
  (set-eglot-client! '(python-mode python-ts-mode) '("ty" "server")))

;; Not necessary for lsp-mode users, because `ty-ls' is already priority = -1
;; (lower = higher priority). Including this for posterity:
(after! python
  (set-lsp-priority! 'ty-ls -5)) ; default is -1

Formatter

Formatting is handled by the doom-module::editor format module. Python buffers use black, by default. ruff is also supported:

;;; Add to $DOOMDIR/config.el
(after! python
  (set-formatter! 'ruff :modes '(python-mode python-ts-mode)))

Formatters can also be set per-project in a .dir-locals.el file or file-local variables. See doom-module::editor format's documentation for details.

TODO Usage

󱌣 This module's usage documentation is incomplete. Complete it?

This module supports LSP. It requires an LSP server, like ty (recommended). See [[Language Server Protocol Support][LSP Support]].

To enable support for auto-formatting with black enable [[doom-module::editor format]].

Keybindings

Binding Description
<localleader> c c Compile Cython buffer
<localleader> i i Insert missing imports
<localleader> i r Remove unused imports
<localleader> i s Sort imports
<localleader> i o Optimize imports
<localleader> t r nosetests-again
<localleader> t a nosetests-all
<localleader> t s nosetests-one
<localleader> t v nosetests-module
<localleader> t A nosetests-pdb-all
<localleader> t O nosetests-pdb-one
<localleader> t V nosetests-pdb-module
<localleader> t f python-pytest-file
<localleader> t k python-pytest-file-dwim
<localleader> t t python-pytest-function
<localleader> t m python-pytest-function-dwim
<localleader> t r python-pytest-repeat
<localleader> t p python-pytest-popup

TODO Configuration

󱌣 This module's configuration documentation is incomplete. Complete it?

The arguments passed to the ipython or jupyter shells can be altered through these two variables:

;; in $DOOMDIR/config.el
(setq +python-ipython-repl-args '("-i" "--simple-prompt" "--no-color-info"))
(setq +python-jupyter-repl-args '("--simple-prompt"))

Troubleshooting

There are no known problems with this module. Report one?

Frequently asked questions

This module has no FAQs yet. Ask one?

TODO Appendix

󱌣 This module has no appendix yet. Write one?