Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Use python -c to invoke pylint and flake8 #1113
referenced this pull request
Sep 28, 2016
@cpitclaudel I'd go for
Generally I think we should slowly move to use
I looked into this again, but there's a problem I didn't consider at the time: backwards compatibility. If people have custom paths for flake8 or pylint, this change will break them.
There's multiple ways to proceed.
Not easily (at least I think, but I'd like to be proven wrong); Flycheck has a pretty deeply-embedded notion of checker executables, where each checker has it's own binary + arguments passed to it.
Not especially pushing for this PR, but one use-case I have where calling pylint through
This is the error I get in emacs:
I fixed that in another way, by adding:
(with-eval-after-load 'flycheck (setq flycheck-command-wrapper-function (lambda (command) (if (null (string-match "pylint" (car command))) command (let* ((new-prefix (replace-regexp-in-string "pylint$" "python" (car command))) (new-rest (append '("-m" "pylint") (cdr command))) (new-command (append (list new-prefix) new-rest))) new-command)))))
I also needed to set the default-directory to be the project root instead of the file's directory because other
((nil . ((eval . (setq default-directory (locate-dominating-file default-directory ".dir-locals.el"))))))
EDIT: corrected the
I'm not sure it's worth hanging onto backward compatibility on this one.
In this case, there is an even simpler trick:
(setf (flycheck-checker-get 'python-flake8 'command) (cddr (flycheck-checker-get 'python-flake8 'command))
would drop the
I updated the PR, but there's one more issue. From the docs of
The addition of the current directory means that large projects with names that conflict with the standard library, like Sphinx, can't be checked:
(this happens because Sphinx contains a "locale" module.
LGTM. I'm not convinced of the need for backward-compatibility on this one, but I don't write enough Python, so I'll trust your judgment.
This can go into