Search code examples
pythoncythonpylint

Options for linting Cython code


I have a Cython module that I would like to lint PEP8 style, however pylint syntax errors on Cython cdef syntax. Does anyone have a suggestion about how to maintain Python coding standards for Cython code?


Solution

  • I use Sublime Text editor with SublimeLinter Flake8 package.

    My Flake8 config is:

    "flake8": {
                "@disable": false,
                "args": [
                    "--doctests"
                ],
                "builtins": "",
                "excludes": [],
                "ignore": "",
                "ignore_match": {
                    "pyx": [
                        "SyntaxError"
                    ]
                },
                "jobs": "1",
                "max-complexity": 7,
                "max-line-length": null,
                "select": "",
                "show-code": false
            },
    

    "ignore_match" key is used to define regular expressions that ignore some reported errors by a linter.

    In this case I used it to ignore syntaxis errors in .pyx files. You can define new expressions to meet your needs.

    Sorry because it's not a Cython linter, it's just a trick to make Python linter useful.

    More info in sublimelinter official docs.