I use flycheck-mode as my syntax checker/linter for Python. It works great for the most part, however I can't get it to warn me when I have gone over a specified line length.

I am using flake8 as my checker for Python, and have confirmed this with flycheck-verify-setup. The output from this command in a python-mode buffer is:

Syntax checkers for buffer config.py in python-mode:

- predicate:  t
- executable: Found at /usr/bin/flake8

- predicate:  nil
- executable: Not found

- predicate:  t
- executable: Found at /usr/bin/python

The following checker is explicitly selected for this buffer:

- major mode: `python-mode' supported
- predicate:  t
- executable: Found at /usr/bin/flake8

Flycheck Mode is enabled.  Use C-u C-c ! x to enable disabled

The checking works in general, so if I have the following Python code:

import re
long_string = "foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"
class Foo():

I get two warnings from flycheck:

're' imported but unused [F401]
expected 2 blank lines, found 0 [E302]

I do not, however, get a warning that long_string is too long. I have tried setting:

(setq-default flycheck-flake8-maximum-line-length 79)

in my init file as suggested here. I have tried configuring flake8 with a flake8 file in my ~/.config/ directory, as described here, which I assume flycheck is supposed to respect, based on this answer. I have also tried setting the value of flycheck-flake8rc to point to that flake8 file. I have tried using a local configuration file within a project as described here. None of these have worked for me. Instead, flycheck seems to ignore any flake8 config I try to give it, and will not warn about line length. This is the case even when I use emacs -Q, initialize packages, and enable global-flycheck-mode - although, in this case the output of flycheck-verify-setup is the same. Any suggestions how I might be able to:

  1. Get flycheck-mode to respect my flake8 configuration file?
  2. Get flycheck-mode to warn me about going over a specified line length?

Question 2 would be solved, in theory, by any solution to question 1, because I could set, e.g.:

max-line-length = 79

in my configuration file, but I would be satisfied with a solution to question 2 alone. Thank you!

  • 1
    Can you run C-c ! C-c python-flake8 to check how Flycheck invokes flake8 in an affected buffer?
    – user227
    May 30, 2016 at 16:48
  • Besides, please note that you can just use setq for the line length option and that it's flycheck-flake8rc (note the dash).
    – user227
    May 30, 2016 at 16:52
  • @lunaryorn thanks for the suggestions and catching my typo. Actually, I got the suggestion to use setq-default from your comment on this issue: github.com/flycheck/flycheck/issues/378. I tried setq as well, and it didn't make a difference. Also, you suggestion to run C-c ! C-c python-flake8 brought something very interesting to my attention: this command still doesn't warn about lines that are too long, but it shows the command being run as flake8 --format\=default --max-line-length 79 - < /tmp/test.py, so it seems like it is checking line length. Does this illuminate things?
    – elethan
    Jun 1, 2016 at 13:16
  • That comment was over two years ago… things change, please don't dig too far in the past. The issue lies elsewhere, and not with Flycheck as it seems. I can't reproduce it; if I run Flycheck with flake8 over your code sample I see a warning about the line being too long. What's your flake8 version?
    – user227
    Jun 1, 2016 at 13:28
  • @lunaryorn my flake8 version is 2.5.4. But you are right, it seems like the issue is independent of flycheck and even Emacs, since using flake8 from the command line outside of Emacs also doesn't expose the line length issue...I will do some more investigating now that I have this new information. Thanks for your help!
    – elethan
    Jun 1, 2016 at 13:36

1 Answer 1


I don't use flymake mode directly. But I use elpy which uses flymake internally and works well.

You can install using M-x package-install elpy.

Next time, when you open a python file, you will get a warning like this

enter image description here

  • Thank you! I am a long time user of elpy and have quite a bit of affection for that package, but I have been giving anaconda-mode a try for the last few weeks. That mode's strength compared to elpy (in my opinion) is it's simplicity and small feature set. However, that is also a weakness in this case I guess, because anaconda-mode doesn't have integrated syntax checking, so I am trying to supplement with flycheck. I admit that all the things I am complaining about in this question work fine for me with elpy.
    – elethan
    May 27, 2016 at 14:24

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.