Skip to main content

A linter for Cython files

Project description

Build Status Coverage pre-commit.ci status

cython-lint

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

Installation

$ pip install cython-lint

Usage as a pre-commit hook

See pre-commit for instructions

Sample .pre-commit-config.yaml:

-   repo: https://github.com/MarcoGorelli/cython-lint
    rev: v0.7.0
    hooks:
    -   id: cython-lint

Command-line example

$ 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

Configuration

The following configuration options are available:

  • exclude lines by including a # no-cython-lint comment (analogous to # noqa in flake8);
  • use the command-line argument --max-line-length to control the maximum line length used by pycodestyle;
  • use the command-line argument --no-pycodestyle if you don't want the pycodestyle checks.

Which checks are implemented?

  • variable defined but unused
  • variable imported but unused
  • comma after base type definition (e.g. cdef ndarray, arr)
  • f-string without placeholders
  • dict key repeated
  • dict key variable repeated
  • if-statement with tuple condition (always true...)
  • assert statement with tuple condition (always true...)
  • dangerous default value
  • pycodestyle nitpicks, which you can turn off with --no-pycodestyle

More to come! Requests welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cython_lint-0.7.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

cython_lint-0.7.0-py2.py3-none-any.whl (8.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file cython_lint-0.7.0.tar.gz.

File metadata

  • Download URL: cython_lint-0.7.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for cython_lint-0.7.0.tar.gz
Algorithm Hash digest
SHA256 139bd51d3dc25471968d3a8dd162aefa5344660d95767c681275a28fee20c078
MD5 a6ea0ae91efe61ef314182fb2417ae09
BLAKE2b-256 aae5a94f1d71f0e1679d19f5aafd4981ccdc4e8fd673e4c4bd5345fdbd4526aa

See more details on using hashes here.

File details

Details for the file cython_lint-0.7.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for cython_lint-0.7.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 754fa4ae9b7845492890a7cd2cc9ec9fff969c3bcc1b1852ef768b9f248e6848
MD5 efd3e3309e9e678f08c78c6e17eb86d5
BLAKE2b-256 d4474934aedfb93185372440114777d2729525534b13132797a7cb1c56fb66c1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page