Skip to content
Advertisement

pylint: Exclude directory

Suppose I have the following directory structure:

adir/
  __init__.py
  afile.py
bdir/
  __init__.py
  bfile.py
  adir/
    __init__.py
    afile.py

I want to run pylint on everything, except the directory bdir/adir.

Is there any way to do this? Things that do not work:

  • --ignore=bdir/adir
  • --ignore_patterns=.*bdir/adir.*
  • Any of the answers in this similar post
  • --ignore=adir (this will ignore both of the adir‘s – not what I want).

It seems that pylint’s ignore-filters only work with the name of the file or directory, not the full path.

Is there any way to achieve this?

Advertisement

Answer

It should be --ignore-paths=bdir/adir. Works both on Windows and Linux.

Regarding --ignore_patterns=.*bdir/adir.*:

  • it contains typo: --ignore_patterns -> --ignore-patterns
  • according to documentation:

ignore-patterns

Files or directories matching the regex patterns are skipped. The regex matches against base names, not paths. The default value ignores emacs file locks

Default: ^.#

You specify not a base name (it includes parent folder).

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement