msherry / flycheck-pycheckers

Multiple syntax checker for Python in Emacs, using Flycheck
GNU General Public License v3.0
63 stars 23 forks source link

flake8 config is ignored #29

Closed ghost closed 5 years ago

ghost commented 5 years ago

I have a .flake8 and setup.cfg with ignore = C812 (trailing commas). The warning does not appear when running flake8 manually, but I still get the flake8 message about cli.py from flycheck-pycheckers. It does work if I put extra_ignore_codes = C812, but that seems like it shouldn't be necessary.

Here's a demo repo https://github.com/apnewberry/demo

flycheck-pycheckers 0.11.5 flake8 3.5.0 (flake8_commas: 2.0.0, mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0) CPython 3.6.6 on Linux emacs 26.1 python 3.6 ubuntu 18.04

Related issue: https://github.com/msherry/flycheck-pycheckers/issues/12

msherry commented 5 years ago

Thanks for the report! I'll take a look at this and see what I can do.

I notice that you have flake8_commas installed -- presumably you have a good reason for this, but it looks like it doesn't get installed by default, and I don't get this error message unless I install that package manually. As a temporary workaround for this specific error only (in addition to the ones you've already named, of course), you could stop installing that package if you don't want it to actually report this error. Obviously this isn't a solution to the more general problem of the flake8 config file being ignored.

msherry commented 5 years ago

@apnewberry This should be resolved, please let me know your results (I tested with your example repo and it worked for me). Please note that issues mentioned in #12 are still in effect, so you will essentially have to figure out the interaction with flycheck-pycheckers-ignore-codes locally -- I set that variable to nil to test this.

ghost commented 5 years ago

Thanks for looking into it! I upgraded to Flycheck-Pycheckers 0.11-6-g163443f but see no change in the behavior while flake8-commas is installed (good point about the plugin!). I'll go with extra_ignore_codes for now.

I use flake8-commas for its "[C818] trailing comma on bare tuple prohibited" option to avoid accidental tuples like

x = f(
    arg1,
    arg2,
),
msherry commented 5 years ago

It looks like flake8 supports an --extend-ignore option, which addresses some of the problems of #12 and #14. Would you be able to try this patch and let me know if it solves your issue more simply than messing with flycheck-pycheckers-ignore-codes? It worked for me on the demo repo.

diff --git a/bin/pycheckers.py b/bin/pycheckers.py
index 5a7db98..9a8a118 100755
--- a/bin/pycheckers.py
+++ b/bin/pycheckers.py
@@ -486,9 +486,7 @@ class Flake8Runner(LintRunner):
         # type: (str) -> Iterable[str]
         args = []
         if self.ignore_codes is not None:
-            # We're explicitly ignoring something, even if that something is
-            # nothing (i.e. `--ignore=`, meaning ignore nothing)
-            args.append('--ignore=' + ','.join(self.ignore_codes))
+            args.append('--extend-ignore=' + ','.join(self.ignore_codes))

         config_file = self.find_config_file('flake8_config_file', '.flake8')
         if config_file:
msherry commented 5 years ago

Oops, note that --extend-ignore is only available in flake8 3.6.0, and it looks like you're running 3.5.0. I think this flag was added to enable what I'm trying to do here, but I'm not sure how to accomplish this behavior beyond what was done in #12 without it.

ghost commented 5 years ago

I upgraded flake8 and made that patch change. It seems to be working when pycheckers.py is executed manually but not in emacs.

My .emacs has

(require 'flycheck-pycheckers)
(setq flycheck-pycheckers-checkers '(pylint flake8))

(with-eval-after-load 'flycheck
  (add-hook 'flycheck-mode-hook #'flycheck-pycheckers-setup))

(setq flycheck-pycheckers-venv-root "~/.envs"
      flycheck-pycheckers-max-line-length 90)
msherry commented 5 years ago

I noticed that I had not considered all config files that flake8 might use (I was only checking .flake8, but not setup.cfg or tox.ini, which are also used). The latest version should check all of these.

ghost commented 5 years ago

Yep that works, thank you!

failable commented 3 years ago

@msherry Hi, I can't get the package work with setup.cfg (simply been ignored). Do I need extra setup for that? Thanks!

msherry commented 3 years ago

@liebkne Can you open a new issue with enough information for me to help debug the issue? It seems like the latest version of flycheck-pycheckers should support setup.cfg based on the resolution of this ticket, so your issue sounds separate from this one.