A linter for Cython files
Project description
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!
- open library
- pandas
- pylibssh
- pymatgen
- RAPIDS cuspatial
- RAPIDS cudf
- RAPIDS Memory Manager
- scikit-image
- scipy
- yt
In addition:
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.13.0
hooks:
- id: cython-lint
- id: double-quote-cython-strings
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 (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
inflake8
); - 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?
- 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!
Project details
Release history Release notifications | RSS feed
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.13.0.tar.gz
(12.4 kB
view details)
Built Distribution
File details
Details for the file cython_lint-0.13.0.tar.gz
.
File metadata
- Download URL: cython_lint-0.13.0.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9adffc8e9a8f7d9f46117e1f61322ea7ee0f770c1f0e3af9e312d40776f01ee |
|
MD5 | 632035bf1940673d6c16400ad7603429 |
|
BLAKE2b-256 | 7fb21669a996bf04bb0e3f23aaa6967a84ad9b48203e874b78b9f8f5d8bd923a |
Provenance
File details
Details for the file cython_lint-0.13.0-py2.py3-none-any.whl
.
File metadata
- Download URL: cython_lint-0.13.0-py2.py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b5d808aa6d122f8663ea05a8ed0dc7382c7adcb7b4050f597dc10bfae2b2f59 |
|
MD5 | 00411811ecc3a3a8c11cc628336b4bcf |
|
BLAKE2b-256 | e62f99d309c33fd439fedd846aa788e71aed877b156543628906a556e3f6e866 |