ament / ament_lint

Apache License 2.0
38 stars 107 forks source link

[ament_flake8] Exclude directories / file patterns defined in config file are ignored #382

Closed danrauch closed 2 years ago

danrauch commented 2 years ago

Since commit a72d149eac6cebdcf6e47cf4a6feaf46ed7778d8 "exclude" parameters defined in the ament_flake8.ini file are ignored.

Steps to reproduce:

  1. exclude a file in ament_flake8.ini via the exclude = "filename.py" parameter
  2. introduce a flake8-relevant formatting error in the excluded file
  3. run flake8 test (e.g. for a ros2 package)
  4. observe test failure
methylDragon commented 2 years ago

I'll need to do some additional testing, but I suspect the CLI call that gets generated from #335 is causing any exclude directives in the config file to get overwritten.

flake8 ... --config=XXX --exclude=XXX

There are three some approaches I can see to resolve this:

  1. Only use extend-exclude in the config file
  2. Only use extend-exclude when appending to CLI args (since it gets appended after the config file)
  3. Introduce logic to parse the config file, pull out exclude args, and extend the list sent to the CLI exclude arg instead.

I would think (2) would be good, but it will change behavior a bit, specifically, in the case where the config file doesn't have an exclude directive, the default excludes for flake8 will be in play when they wouldn't before: .svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.nox,.eggs,*.egg, it's an acceptable trade-off to me.

methylDragon commented 2 years ago

(1) and (2) don't work.

We'll need to implement (3)

Edit: I'm implementing a fix

methylDragon commented 2 years ago

Fix here: https://github.com/ament/ament_lint/pull/387