I am using flycheck for for Python. I want flycheck to detect any errors right away when any Python file is opened. Currently it can detect if there is a modification and save operation is performed.

Let's say I have following code in hello.py file:

#!/usr/bin/env python3

import os


Than I have commented out print(os.getpid()) and close the file and reopened it. At this stage flycheck does not detect that 'os' imported but unused [F401]. I have to make some moditifications and save the file for it do detect it.

my setup:

(require 'flycheck)
(require 'flycheck-mypy)

(setq python-shell-interpreter "python3"
      python-shell-prompt-detect-failure-warning nil
      flycheck-python-pycompile-executable "python3"
      python-shell-completion-native-enable nil
      python-shell-completion-native-disabled-interpreters '("python3")
      elpy-shell-echo-output nil ; 

(add-hook 'python-mode-hook
      (lambda ()
        ;; (setq flycheck-mypyrc "~/venv/bin/pylint")
        (setq flycheck-python-pylint-executable "~/venv/bin/pylint")
        (local-set-key (kbd "C-c C-b") 'break-point)
        (setq flycheck-pylintrc "~/.pylintrc")))

I am also using Getting flycheck “jump to next/previous error” to cycle, it won't also able to detect it till save is done.

1 Answer 1


You can try the following:

(setq flycheck-check-syntax-automatically '(save idle-buffer-switch idle-change new-line mode-enabled)
      flycheck-idle-buffer-switch-delay 0)

This tells flycheck to run immediately "after you switch to a buffer". The other choices like save, idle-change, new-line, and mode-enabled are already configured as the default choices. The second option reduces the delay before the check is triggered. There is also flycheck-idle-change-delay which you can reduce if you want.

  • What would be the smallest value I can reduce for flycheck-idle-change-delay ? or is there any recommended value for it?
    – alper
    Commented Jan 28, 2021 at 10:12
  • The default value is 0.5, you can make it 0. Commented Jan 29, 2021 at 4:29
  • Sorry for late response but I observe that if the buffer is not saved this does not help
    – alper
    Commented Oct 29, 2021 at 14:47
  • Sorry for late response, would it be wise to keep (setq flycheck-check-syntax-automatically '(save mode-enable)) setting as well?
    – alper
    Commented Oct 29, 2021 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.