# Eglot Python: How to add "'--additional-builtins" to syntax checker (flake8?)

**URL:** <https://forum.systemcrafters.net/t/eglot-python-how-to-add-additional-builtins-to-syntax-checker-flake8/948>\
**Category:** Emacs\
**Created:** [August 26, 2024, 5:47pm UTC](https://forum.systemcrafters.net/t/eglot-python-how-to-add-additional-builtins-to-syntax-checker-flake8/948 "2024-08-26T17:47:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![buhtz](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@buhtz](https://forum.systemcrafters.net/u/buhtz)\
**Post date:** [August 26, 2024, 5:47pm UTC](https://forum.systemcrafters.net/t/eglot-python-how-to-add-additional-builtins-to-syntax-checker-flake8/948/1 "2024-08-26T17:47:22Z")

</div>

When it comes to Python some linters (e.g. PyLint) offer a option “–additional-builtins” to define extra names that should be ignored (or considered as Python build ins). This is help full when you use localziation via GNU gettext.

This works well when using linters on shell. But not when using Emacs with eglot.

This functions are always marked as errors (red underscores):

```
_('translate me')
ngettext('one', 'more', 2)

```

I am far away from being a Lisp expert. I setup my Emacs based on Davids videos. I am using eglot and python-language-server (pylsp) in the back.

I am even not sure which linter is used by eglot or the language server. I am even not sure who execute the linter: Eglot or the language server? Based on my “_Messages_” buffer I am assuming it is “flake8”. There seems to be a command line option [–buildins=](https://flake8.pycqa.org/en/latest/user/options.html#cmdoption-flake8-builtins) offering that behavior I need.

But I don’t know how to start in Emacs/eglot/pylsp/somewherelese to add this option.

**EDIT** :  
I set this alias in my bash: `alias flake8="flake8 --builtins=_,ngettext" `. This works on shell but has no effect on the flake8 instance used by my Emacs environment.

**EDIT2** :  
I am so doomed that I also “asked” ChatGPT. Shame on me. Because of that I added the `:config` section to this python config. But without effect but also no error.

```auto
;; ...snipped...

(use-package python
  :ensure nil ; in-build!
  :hook
  (python-mode . (lambda ()
   		   (if (not (string-equal (system-name) "quark"))
   		       (eglot-ensure)))
  )
  ;; (python-mode . eglot-ensure)
  (python-mode . ws-butler-mode)
  (python-mode . hs-minor-mode)
  :custom
  (python-shell-interpreter "python3")
  :config
  (setq-default eglot-workspace-configuration
    '((:pylsp . (:plugins (:pyflakes (:enabled t)
                           :flake8 (:enabled t
                                    :builtins ["_", "ngettext"]
                                    )
                           )
                )
     ))
  )
)

;; ...snipped...

(use-package eglot
  ;; :hook
  ;; (prog-mode . eglot-ensure)
  :bind (:map eglot-mode-map
	      ("C-c a r" . #'eglot-rename))
  :custom
  (eglot-autoshutdown t)
  (flymake-no-changes-timeout 5)
  )

```

---

<div class="post-metadata">

**Author:** ![ech](https://avatars.discourse-cdn.com/v4/letter/e/f08c70/32.png) [@ech](https://forum.systemcrafters.net/u/ech)\
**Post date:** [September 21, 2024, 8:08pm UTC](https://forum.systemcrafters.net/t/eglot-python-how-to-add-additional-builtins-to-syntax-checker-flake8/948/2 "2024-09-21T20:08:18Z")

</div>

I’m pretty bad at Emacs config, but I’ve managed to set up a more or less productive C++ dev environment for myself. I’ve had a similar need to pass extra cmd line args to LSP server like follows:

```lisp
(use-package eglot
  :config
  (add-to-list 'eglot-server-programs
               '((c++-mode c-mode) "clangd" "--enable-config" "--background-index")))

```

---

<div class="post-metadata">

**Author:** ![alphapapa](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@alphapapa](https://forum.systemcrafters.net/u/alphapapa)\
**Post date:** [September 22, 2024, 9:54am UTC](https://forum.systemcrafters.net/t/eglot-python-how-to-add-additional-builtins-to-syntax-checker-flake8/948/3 "2024-09-22T09:54:16Z")

</div>

I think you first need to find out which LSP server Eglot is using for Python. It has autodetection, but you can use a prefix argument to select a specific one, I think.

Then you can look in that LSP server’s documentation about linting configuration. It may or may not mean making the change in Eglot’s config.

---

<div class="post-metadata">

**Author:** ![Glenneth](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/glenneth/32/11_2.png) [@Glenneth](https://forum.systemcrafters.net/u/Glenneth)\
**Post date:** [December 13, 2024, 2:24am UTC](https://forum.systemcrafters.net/t/eglot-python-how-to-add-additional-builtins-to-syntax-checker-flake8/948/4 "2024-12-13T02:24:45Z")

</div>

Another random test post from within emacs. I apologise in advance, I am just testing out _features_. Thanks.
