Rustem
Rustem

Reputation: 2932

Using proper virtualenv and flake8 config with Flycheck

How can I use configured virtualenv and flake8 settings file (setup.cfg in root of project), for flycheck in emacs?

Upvotes: 3

Views: 2208

Answers (2)

Rustem
Rustem

Reputation: 2932

I spent some time to find right solution and decided to implement my own:

flycheck-local-flake8

This is plugin for flycheck-flake8 checker, simply uses flake8 from required virtualenv and setup.cfg from root of the python project.

Upvotes: 2

Chris
Chris

Reputation: 137215

There are a number of plugins for working with virtualenvs. For example, with pyvenv installed I can use the pyvenv-workon command to select a virtualenv from $WORKON_HOME.

virtualenvwrapper and python-environment provide similar support, and all three are available on MELPA.

Flycheck has an option flycheck-flake8rc:

Configuration file for `python-flake8'.

If you have per-project configuration files, it might be easiest to create .dir-locals.el files in the root of each project that sets flycheck-flake8rc to the appropriate value, e.g.

((python-mode
  (flycheck-flake8rc . "/path/to/setup.cfg")))

I would advise not tracking .dir-locals.el in whatever version control system you are using, though of course that is up to you.

Upvotes: 2

Related Questions