cython-lint


Namecython-lint JSON
Version 0.16.6 PyPI version JSON
download
home_pageNone
SummaryLint Cython files
upload_time2024-11-10 12:24:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build Status](https://github.com/MarcoGorelli/cython-lint/workflows/tox/badge.svg)](https://github.com/MarcoGorelli/cython-lint/actions?workflow=tox)
[![Coverage](https://codecov.io/gh/MarcoGorelli/cython-lint/branch/main/graph/badge.svg)](https://codecov.io/gh/MarcoGorelli/cython-lint)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/MarcoGorelli/cython-lint/main.svg)](https://results.pre-commit.ci/latest/github/MarcoGorelli/cython-lint/main)

cython-lint
===========

Everything ``flake8`` used to do (by accident), plus much more.

A tool and pre-commit hook to lint Cython files.

## Used by

Here's some major projects using ``cython-lint`` - is yours missing? Feel free to open a pull request!

- [arrow-adbc](https://github.com/apache/arrow-adbc)
- [ansible-pylibssh](https://github.com/ansible/pylibssh)
- [arrow](https://github.com/apache/arrow)
- [CuPy](https://github.com/cupy/cupy)
- [frozenlist](https://github.com/aio-libs/frozenlist)
- [open library](https://github.com/internetarchive/openlibrary)
- [pandas](https://github.com/pandas-dev/pandas)
- [pymatgen](https://github.com/materialsproject/pymatgen)
- [PyRFC](https://github.com/SAP/PyRFC)
- [RAPIDS cuspatial](https://github.com/rapidsai/cuspatial)
- [RAPIDS cudf](https://github.com/rapidsai/cudf)
- [RAPIDS Memory Manager](https://github.com/rapidsai/rmm)
- [sagemath/sage](https://github.com/sagemath/sage/issues)
- [scikit-image](https://github.com/scikit-image/scikit-image)
- [scikit-learn](https://github.com/scikit-learn/scikit-learn)
- [scipy](https://github.com/scipy/scipy)
- [spaCy](https://github.com/explosion/spaCy)
- [yarl](https://github.com/aio-libs/yarl)
- [yt](https://github.com/yt-project/yt)

## Installation

```console
$ pip install cython-lint
```

## Usage as a pre-commit hook

See [pre-commit](https://github.com/pre-commit/pre-commit) for instructions

Sample `.pre-commit-config.yaml`:

```yaml
-   repo: https://github.com/MarcoGorelli/cython-lint
    rev: v0.16.6
    hooks:
    -   id: cython-lint
    -   id: double-quote-cython-strings
```

## Command-line example

```console
$ cython-lint my_file_1.pyx my_file_2.pyx
my_file_1.pyx:54:5: 'get_conversion_factor' imported but unused
my_file_2.pyx:1112:38: 'mod' defined but unused (try prefixing with underscore?)
my_file_3.pyx:4:9: dangerous default value!
my_file_3.pyx:5:9: comma after base type in definition
```

## Configuration

The following configuration options are available:
- exclude lines by including a ``# no-cython-lint`` comment (analogous to ``# noqa`` in ``flake8``);

as well as the following command-line arguments:
- ``--max-line-length`` to control the maximum line length used by pycodestyle;
- ``--no-pycodestyle`` if you don't want the pycodestyle checks;
- ``--ignore`` if you want to ignore some specific pycodestyle checks;
- ``--files`` to pass a Regex pattern with which to match files to include;
- ``--exclude`` to pass a Regex pattern with which to match files to exclude.

Configuration can be set project-wise in a `pyproject.toml` file at the root of the project.
Here's an example `pyproject.toml`:
```
[tool.cython-lint]
max-line-length = 88
ignore = ['E503', 'E504']
exclude = 'my_project/excluded_cython_file.pyx'
```

## Which checks are implemented?

- assert statement with tuple condition (always true...)
- comma after base type definition (e.g. ``cdef ndarray, arr``)
- comparison between constants
- dangerous default value
- dict key repeated
- dict key variable repeated
- f-string without placeholders
- if-statement with tuple condition (always true...)
- late-binding closures https://docs.python-guide.org/writing/gotchas/#late-binding-closures
- pointless string statement
- ``pycodestyle`` nitpicks (which you can turn off with ``--no-pycodestyle``)
- repeated element in set
- ``.strip``, ``.rstrip``, or ``.lstrip`` used with repeated characters
- unnecessary list index lookup
- unnecessary import alias
- variable defined but unused
- variable imported but unused

In addition, the following automated fixers are implemented:

- double-quote-cython-strings (replace single quotes with double quotes, like the ``black`` formatter does)

More to come! Requests welcome!

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cython-lint",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com>",
    "download_url": "https://files.pythonhosted.org/packages/03/e7/a1e6ca82be6a72542f9aa142619dcdd68ed9a000bab4731c61af3a47a81c/cython_lint-0.16.6.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://github.com/MarcoGorelli/cython-lint/workflows/tox/badge.svg)](https://github.com/MarcoGorelli/cython-lint/actions?workflow=tox)\n[![Coverage](https://codecov.io/gh/MarcoGorelli/cython-lint/branch/main/graph/badge.svg)](https://codecov.io/gh/MarcoGorelli/cython-lint)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/MarcoGorelli/cython-lint/main.svg)](https://results.pre-commit.ci/latest/github/MarcoGorelli/cython-lint/main)\n\ncython-lint\n===========\n\nEverything ``flake8`` used to do (by accident), plus much more.\n\nA tool and pre-commit hook to lint Cython files.\n\n## Used by\n\nHere's some major projects using ``cython-lint`` - is yours missing? Feel free to open a pull request!\n\n- [arrow-adbc](https://github.com/apache/arrow-adbc)\n- [ansible-pylibssh](https://github.com/ansible/pylibssh)\n- [arrow](https://github.com/apache/arrow)\n- [CuPy](https://github.com/cupy/cupy)\n- [frozenlist](https://github.com/aio-libs/frozenlist)\n- [open library](https://github.com/internetarchive/openlibrary)\n- [pandas](https://github.com/pandas-dev/pandas)\n- [pymatgen](https://github.com/materialsproject/pymatgen)\n- [PyRFC](https://github.com/SAP/PyRFC)\n- [RAPIDS cuspatial](https://github.com/rapidsai/cuspatial)\n- [RAPIDS cudf](https://github.com/rapidsai/cudf)\n- [RAPIDS Memory Manager](https://github.com/rapidsai/rmm)\n- [sagemath/sage](https://github.com/sagemath/sage/issues)\n- [scikit-image](https://github.com/scikit-image/scikit-image)\n- [scikit-learn](https://github.com/scikit-learn/scikit-learn)\n- [scipy](https://github.com/scipy/scipy)\n- [spaCy](https://github.com/explosion/spaCy)\n- [yarl](https://github.com/aio-libs/yarl)\n- [yt](https://github.com/yt-project/yt)\n\n## Installation\n\n```console\n$ pip install cython-lint\n```\n\n## Usage as a pre-commit hook\n\nSee [pre-commit](https://github.com/pre-commit/pre-commit) for instructions\n\nSample `.pre-commit-config.yaml`:\n\n```yaml\n-   repo: https://github.com/MarcoGorelli/cython-lint\n    rev: v0.16.6\n    hooks:\n    -   id: cython-lint\n    -   id: double-quote-cython-strings\n```\n\n## Command-line example\n\n```console\n$ cython-lint my_file_1.pyx my_file_2.pyx\nmy_file_1.pyx:54:5: 'get_conversion_factor' imported but unused\nmy_file_2.pyx:1112:38: 'mod' defined but unused (try prefixing with underscore?)\nmy_file_3.pyx:4:9: dangerous default value!\nmy_file_3.pyx:5:9: comma after base type in definition\n```\n\n## Configuration\n\nThe following configuration options are available:\n- exclude lines by including a ``# no-cython-lint`` comment (analogous to ``# noqa`` in ``flake8``);\n\nas well as the following command-line arguments:\n- ``--max-line-length`` to control the maximum line length used by pycodestyle;\n- ``--no-pycodestyle`` if you don't want the pycodestyle checks;\n- ``--ignore`` if you want to ignore some specific pycodestyle checks;\n- ``--files`` to pass a Regex pattern with which to match files to include;\n- ``--exclude`` to pass a Regex pattern with which to match files to exclude.\n\nConfiguration can be set project-wise in a `pyproject.toml` file at the root of the project.\nHere's an example `pyproject.toml`:\n```\n[tool.cython-lint]\nmax-line-length = 88\nignore = ['E503', 'E504']\nexclude = 'my_project/excluded_cython_file.pyx'\n```\n\n## Which checks are implemented?\n\n- assert statement with tuple condition (always true...)\n- comma after base type definition (e.g. ``cdef ndarray, arr``)\n- comparison between constants\n- dangerous default value\n- dict key repeated\n- dict key variable repeated\n- f-string without placeholders\n- if-statement with tuple condition (always true...)\n- late-binding closures https://docs.python-guide.org/writing/gotchas/#late-binding-closures\n- pointless string statement\n- ``pycodestyle`` nitpicks (which you can turn off with ``--no-pycodestyle``)\n- repeated element in set\n- ``.strip``, ``.rstrip``, or ``.lstrip`` used with repeated characters\n- unnecessary list index lookup\n- unnecessary import alias\n- variable defined but unused\n- variable imported but unused\n\nIn addition, the following automated fixers are implemented:\n\n- double-quote-cython-strings (replace single quotes with double quotes, like the ``black`` formatter does)\n\nMore to come! Requests welcome!\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Lint Cython files",
    "version": "0.16.6",
    "project_urls": {
        "Bug Tracker": "https://github.com/MarcoGorelli/cython-lint",
        "Homepage": "https://github.com/MarcoGorelli/cython-lint"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "03fa1816c44ecc6f1d32dd03857fd9bd2073d471233131857f989781c47f52ed",
                "md5": "e8691a752847f7e3496b93f01e5c4e3e",
                "sha256": "5057fdbb0ebe41912431293a3d33d1e547c9f2242c5a1426525a14b2b4a869a4"
            },
            "downloads": -1,
            "filename": "cython_lint-0.16.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e8691a752847f7e3496b93f01e5c4e3e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 12910,
            "upload_time": "2024-11-10T12:24:09",
            "upload_time_iso_8601": "2024-11-10T12:24:09.845504Z",
            "url": "https://files.pythonhosted.org/packages/03/fa/1816c44ecc6f1d32dd03857fd9bd2073d471233131857f989781c47f52ed/cython_lint-0.16.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "03e7a1e6ca82be6a72542f9aa142619dcdd68ed9a000bab4731c61af3a47a81c",
                "md5": "65e658e22555701a6f02d22e4e413707",
                "sha256": "829046988d3986443c47183e7ea567a6893d78dfb135144670ffff67d58deb9e"
            },
            "downloads": -1,
            "filename": "cython_lint-0.16.6.tar.gz",
            "has_sig": false,
            "md5_digest": "65e658e22555701a6f02d22e4e413707",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 26523,
            "upload_time": "2024-11-10T12:24:12",
            "upload_time_iso_8601": "2024-11-10T12:24:12.271867Z",
            "url": "https://files.pythonhosted.org/packages/03/e7/a1e6ca82be6a72542f9aa142619dcdd68ed9a000bab4731c61af3a47a81c/cython_lint-0.16.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-10 12:24:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MarcoGorelli",
    "github_project": "cython-lint",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "cython-lint"
}
        
Elapsed time: 0.39384s