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.1
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.1.tar.gz
(8.5 kB
view details)
Built Distribution
File details
Details for the file cython_lint-0.8.1.tar.gz
.
File metadata
- Download URL: cython_lint-0.8.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | de02d5d6a1f4c1257f8b15443417d716480a1cd8197e41969f1b330bbc6b6c9e |
|
MD5 | 68c8a16ea5b6e711b224e9f6584f0ebd |
|
BLAKE2b-256 | 8d37160c2e343d1afd31b127937c57b1020fedefd49f4b3aaddd9dad9e083503 |
Provenance
File details
Details for the file cython_lint-0.8.1-py2.py3-none-any.whl
.
File metadata
- Download URL: cython_lint-0.8.1-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.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b60311cadd892547345b8e17843ea5604353db86a8e68f7c22a1d2072712887 |
|
MD5 | d946d73280f6304d05d2bf0f7eecdad6 |
|
BLAKE2b-256 | 5a6d5961c1077d0c1c5f58d1cc8396d78a4d435a051b272d2f15f46d8f2f65a9 |