Search code examples
pythonsublimetextflake8sublimelinter

Make SublimeLinter flake8 linter only lint .py files


Is there a way to have my SublimeLinter flake8 linter only run on *.py files? I know there is an exclude key in the settings where I can specify files to ignore, but I'm looking for something more like an include setting so I can disable flake8 linting on all non-python files.

My linter settings:

    "linters":
    {
        "flake8": {
            "args": ["--ignore=E251,E501"],
            "disable": false,
            "disable_if_not_dependency": false,
            "env": {},
            "excludes": [],
            "executable": "~/miniconda3/bin/flake8",
            "filter_errors": [],
            "lint_mode": "background",
            "python": 3,
            "selector": "",
            "styles": [{"codes": [""]}],
            "working_dir": ""
        }

Solution

  • from the SublimeLinter docs:

    you'd set selector. this appears to use the textmate selector syntax so you'd want to select something like:

        "selector": "source.python",
    

    matching the textmate selector from the python grammar:

    scopeName: "source.python"