代码之家  ›  专栏  ›  技术社区  ›  Ciantic

pylint按目录忽略

  •  21
  • Ciantic  · 技术社区  · 14 年前

    以下是来自 pylint docs 以下内容:

    --ignore=<file>
        Add <file or directory> to the black list. It should be a base name, not a path. You may set this option multiple times. [current: %default]
    

    不过,我在目录部分的工作上没有运气。

    我有一个名为migrations的目录,其中包含django-south迁移文件。当我输入--ignore=migrations时,它仍然不断地向我提供migrations目录中文件中的错误/警告。

    可能是那样吗 --ignore 不适用于目录吗?

    如果我甚至可以使用regexp来匹配被忽略的文件,它就可以工作了,因为django-south文件都被命名为0001_-something,0002_-something…


    既然我不能让“按目录忽略”工作,我只能用 # pylint: disable-msg-cat=WCREFI 在每个迁移文件之上,它忽略所有pylint错误、警告和信息。

    4 回复  |  直到 6 年前
        1
  •  19
  •   marqueed    13 年前

    添加:

    [MASTER]
    ignore=migrations
    

    到我的。皮林特与皮林特0.25工作。我的问题是与皮德夫,这(似乎)是不尊重我的设置。我认为这是因为它运行的是每个文件的pylint,我认为它绕过了“忽略”检查——不管是模块/目录还是文件。从pydev到pylint的调用如下:

    /path/to/site-packages/pylint/lint.py --include-ids=y /path/to/project/migrations/0018_migration.py
    
        2
  •  8
  •   exhuma    6 年前

    不能给出路径,只能给出目录的“basename”。例如:使用 --ignore=lib 而不是 --ignore-=appengine-toolkit/gaetk/lib .

    问题是你会忽略 全部的 名为的目录 lib .

        3
  •  1
  •   Joe Linoff    6 年前

    虽然这是一个老问题,但当我们搜索堆栈溢出时,它出现在最上面的列表中,所以我在这里发布我们的解决方案,希望它对其他人有用。

    忽略名为的目录树下的子目录 3rdparty ,我们添加了以下内容 ignore-patterns 进入 [MASTER] 报关进口 .pylintrc .

    # Add files or directories matching the regex patterns to the blacklist. The
    # regex matches against base names, not paths.
    # Ignore all .py files under the 3rdparty subdirectory.
    ignore-patterns=**/3rdparty/**/*.py
    

    这解决了pylint-1.7.1的问题。

    我们最初被评论中的“基名”子句混淆了。显然,它接受带有通配符的路径。至少对我们有好处。您的里程可能会有所不同。

        4
  •  -1
  •   badp    14 年前

    然后,您可以利用bash扩展实现以下优势:

    --ignore=migrations/{0000..1000}_something