Search code examples
sublimetextsublimelinterflake8

Ignore 'undefined name' for certain global keywords w/ sublimelinter + flake8


Using a bit of an unusual language, processing-py, which is a sort of python wrapper around the java processing language.

processing-py introduces many global keywords that don't need to be imported. These include functions names like loadPixels() and global variables (constants?) like 'width' (width of screen).

Sublimelinter + flake8 correctly raises F821 undefined name for these. It's not convenient to #noqa, I might as well just turn the linter off at that point. I'd also like to see when I am actually introducing a bogus keyword, such as typoing loadPixels() (good) as laodPixels() (bad).

So is there a way to add a list of exceptions for F821, or otherwise extend the dictionary of known keywords?

I'm also using a custom thTheme with the list of keywords, as part of the processing-py-sublime package.

Thanks!


Solution

  • Don't know if you ever solved your problem, but if you use SublimePythonIDE with SublimeText3, you can add a list of exceptions in either the plugin's User settings or Project settings:

    In User settings, add:

    "pyflakes_ignore": ["background", "ellipse", "fill", "size" ... ]

    In Project settings, add to 'settings' object:

    {
        "settings": {
            // Ignoring for Processing.py projects
            "pyflakes_ignore": ["background",
                                "ellipse",
                                "fill",
                                "size"]
        }
    }