Build your own linter in minutes - from Python code to config files (YAML, JSON, TOML)
Project description
lintkit is a framework for building linters/code checking rules
- Multiple formats: Python-first, but supports YAML, JSON and TOML
- Comprehensive:
noqacomments, file skips and standardized pretty output - Quick: Create and run custom rules in a few lines of code
- Flexible: Rules over file(s), their subelements and more (see Files tutorial)
- Minimal: Gentle learning curve -
<1000lines of code, tutorials, API reference
🚀 Quick start 📚 Documentation 🤝 Contribute 👍 Adopters 📜 Legal
Quick start
[!TIP] Check out more examples (here) to get a better feel of
lintkit.
Below are ~20 lines of code implementing custom linter with
two rules and running it on three files:
import lintkit
# Set the name of the linter
lintkit.settings.name = "NOUTILS"
class _NoUtils(lintkit.check.Regex, lintkit.loader.Python, lintkit.rule.Node):
def regex(self):
# Regex to match util(s) variations in function/class name
return r"_?[Uu]til(s|ities)?"
def values(self):
# Yield class or function names from a Python file
data = self.getitem("nodes_map")
for node in data[self.ast_class()]:
yield lintkit.Value.from_python(node.name, node)
def message(self, _):
return f"{self.ast_class()} name contains util(s) word"
# Concrete rules and their codes
# Disabling linter using noqas supported out of the box!
class ClassNoUtils(_NoUtils, code=0): # noqa: NOUTILS0
# ast type we want to focus on in this rule
def ast_class(self):
return ast.ClassDef
class FunctionNoUtils(_NoUtils, code=1): # noqa: NOUTILS0
def ast_class(self):
return ast.FunctionDef
lintkit.run(["linter.py", "file1.py", "file2.py"])
# Example output
#/path/file1.py:23:17 NOUTILS0: ClassDef name contains util(s) word
#/path/file2.py:73:21 NOUTILS1: FunctionDef name contains util(s) word
Installation
[!TIP] You can use your favorite package manager like
uv,hatchorpdminstead ofpip.
> pip install lintkit
[!NOTE]
lintkitprovides extras (rich,toml,yamlandallcontaining everything) to provide additional functionality.
# To create rules utilizing YAML
> pip install lintkit[rich, yaml]
Learn
Check out the following links to learn more about lintkit:
Contribute
We welcome your contributions! Start here:
Legal
- This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
- This project is copyrighted by open-nudge - the appropriate copyright notice is included in each file.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lintkit-0.2.0.tar.gz.
File metadata
- Download URL: lintkit-0.2.0.tar.gz
- Upload date:
- Size: 38.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82319a0287da0f1fb401307f75991690bd920ba020c48d36eeb29aa9509735a6
|
|
| MD5 |
d19e8e52a137da9f748dc9b7fd3154c8
|
|
| BLAKE2b-256 |
8ee84beb2b9de9eba05076b4c785635a1180e55a8e29d5afe36448ee683deabf
|
Provenance
The following attestation bundles were made for lintkit-0.2.0.tar.gz:
Publisher:
release.yml on open-nudge/lintkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lintkit-0.2.0.tar.gz -
Subject digest:
82319a0287da0f1fb401307f75991690bd920ba020c48d36eeb29aa9509735a6 - Sigstore transparency entry: 452285911
- Sigstore integration time:
-
Permalink:
open-nudge/lintkit@198c3003411015da4a23674287923117be1dad8d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/open-nudge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@198c3003411015da4a23674287923117be1dad8d -
Trigger Event:
release
-
Statement type:
File details
Details for the file lintkit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: lintkit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 40.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f65a03997bdafe56116d3ef0670e51c11d68a91192b924eb634f8130d8cc6f1
|
|
| MD5 |
c6abd361e152ed096d24f7c12804af48
|
|
| BLAKE2b-256 |
d0fb6152b3731252cfa2db7561b30d681d68d1adab4091a731f1006beba0969a
|
Provenance
The following attestation bundles were made for lintkit-0.2.0-py3-none-any.whl:
Publisher:
release.yml on open-nudge/lintkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lintkit-0.2.0-py3-none-any.whl -
Subject digest:
0f65a03997bdafe56116d3ef0670e51c11d68a91192b924eb634f8130d8cc6f1 - Sigstore transparency entry: 452285922
- Sigstore integration time:
-
Permalink:
open-nudge/lintkit@198c3003411015da4a23674287923117be1dad8d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/open-nudge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@198c3003411015da4a23674287923117be1dad8d -
Trigger Event:
release
-
Statement type: