A linter for Cython files
Project description
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.8.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
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?
- 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
- repeated element in set
.strip
,.rstrip
, or.lstrip
used with repeated characters- comparison between constants
- late-binding closures https://docs.python-guide.org/writing/gotchas/#late-binding-closures
pycodestyle
nitpicks, which you can turn off with--no-pycodestyle
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.8.0.tar.gz
(8.4 kB
view details)
Built Distribution
File details
Details for the file cython_lint-0.8.0.tar.gz
.
File metadata
- Download URL: cython_lint-0.8.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d8138f7c8c624cdee58ed9b52ec7a92196642aef98232ba0f801f33c44a12c8 |
|
MD5 | 22a6e4b0bb32f82291f1730cc39f964c |
|
BLAKE2b-256 | 1996fa174749d647b52f584e5632959e9ec604b3ecfa04997afe7993939c96c3 |
Provenance
File details
Details for the file cython_lint-0.8.0-py2.py3-none-any.whl
.
File metadata
- Download URL: cython_lint-0.8.0-py2.py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0d423f0213349e664c2520694002f64b843ac2cd498ebec431787b5f62f1d6c |
|
MD5 | 89aac26c57c9f375a3d5596648b9732c |
|
BLAKE2b-256 | 315245af87b0a3dcb66e5c03b37b919889b3cabb28ec5e3bc6f1f254d4d2fd15 |