Lemming is a tool for formatting and linting code.
Project description
Lemming
Lemming is a tool for formatting and linting your code. With Lemming, everyone will use the same formatters and linters, with the same version.
Installation
Use the package manager pip to install Lemming. Need more help?
pip install python-lemming
Requirements
Lemming requires Python 3.7
Usage
1. Create the config
Lemming's config lives in these places:
- in the
.lemming.toml
file - in the
pyproject.toml
file
Please note, that there must be a lemming
or tool.lemming
key in the config file.
The config looks like this:
fail_fast = false # OPTIONAL, whether or not immediately quit in case of an error
[[formatters]]
name = "some_example" # OPTIONAL, used to identify this formatter. Defaults to packages[0]
packages = ["example"] # REQUIRED, the package(s) to install with pip (might include versions with "==x.y.z")
format_command = "{pyexe} -m example {path}" # REQUIRED, the command to run to format the code ({pyexe} will be replaced with the python executable, {path} with the path passed to Lemming (usually the current working directory: "."))
check_command = "{pyexe} -m example --check {path}" # OPTIONAL, the command to run to check the code (stuff will be replaced just like in format_command)
allow_nonzero_on_format = true # OPTIONAL, if true it is allowed for the format_command to return a non-zero exit status
[[linters]]
name = "other_example" # OPTIONAL, used to identify this linter. Defaults to packages[0]
packages = ["example"] # REQUIRED, same as for formatters
command = "{pyexe} -m example {path}" # REQUIRED, the command to run to lint the code (stuff will be replaced just like in format_command)
run_first = true # OPTIONAL, if true this linter will be ran BEFORE formatters, and other linters. Defaults to false.
2. Run Lemming
After installing Lemming, run
lemming {format,check} .
If you choose format, the format_command
s will be ran, but if you choose check, the check_command
s will be ran. Linters will be ran in both cases.
You can also use Lemming as a GitHub workflow, like this.
CLI usage
Usage: lemming [OPTIONS] COMMAND [ARGS]...
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --version -V Print the version of Lemming and exit. │
│ --install-completion [bash|zsh|fish|powershell|pwsh] Install completion for the specified shell. [default: None] │
│ --show-completion [bash|zsh|fish|powershell|pwsh] Show completion for the specified shell, to copy it or customize the installation. [default: None] │
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ check Check the formatting of your code and run linters. │
│ format Format your code and run linters. │
│ pre-commit Install a pre-commit git hook which will run Lemming. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Check
Usage: lemming check [OPTIONS] PATHS...
Check the formatting of your code and run linters.
╭─ Arguments ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ * paths PATHS... [default: None] [required] │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --quiet-commands,--qc If passed the output of the formatters and linters will be hidden. │
│ --quiet-pip,--qp If passed the output of pip will be hidden. │
│ --verbose -v When passed the logger's threshold will be decreased by 10 (may be passed multiple times) │
│ --quiet -q When passed the logger's threshold will be increased by 10 (may be passed multiple times) │
│ --config FILE The config file to use [default: None] │
│ --only TEXT Only run these formatters/linters (may be passed multiple times) [default: None] │
│ --help Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Format
Usage: lemming format [OPTIONS] PATHS...
Format your code and run linters.
╭─ Arguments ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ * paths PATHS... [default: None] [required] │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --quiet-commands,--qc If passed the output of the formatters and linters will be hidden. │
│ --quiet-pip,--qp If passed the output of pip will be hidden. │
│ --verbose -v When passed the logger's threshold will be decreased by 10 (may be passed multiple times) │
│ --quiet -q When passed the logger's threshold will be increased by 10 (may be passed multiple times) │
│ --config FILE The config file to use. [default: None] │
│ --only TEXT Only run these formatters/linters (may be passed multiple times) [default: None] │
│ --help Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Pre-commit
Usage: lemming pre-commit [OPTIONS]
Install a pre-commit git hook which will run Lemming.
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --git-repository DIRECTORY The root directory of the git repository to use. Defaults to the current working directory. [default: (dynamic)] │
│ --verbose -v When passed the logger's threshold will be decreased by 10 (may be passed multiple times) │
│ --quiet -q When passed the logger's threshold will be increased by 10 (may be passed multiple times) │
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Support
Questions should be asked in the Discussions tab.
Feature requests and bug reports should be reported in the Issues tab.
Security vulnerabilities should be reported as described in our Security policy (in the SECURITY.md file).
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to add entries to the changelog.
For more information, please read the contributing guidelines.
Authors and acknowledgments
A list of nice people who helped this project can be found in the CONTRIBUTORS file.
License
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
Built Distribution
File details
Details for the file python_lemming-0.7.0.tar.gz
.
File metadata
- Download URL: python_lemming-0.7.0.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0099e216d1b1b93ce0a212ded7cccd662bb2cc7f93751a4d5294631f42bd3583 |
|
MD5 | ca6c24510378d8828c421320ae6ac1a3 |
|
BLAKE2b-256 | f537dd8cfa1ecb9ae4051d47f2d80db136874ec3564065fa1a38842cb1b7fb6e |
File details
Details for the file python_lemming-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: python_lemming-0.7.0-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 566cfe84419aeeb7df4dcca97a547b8e587076e7b3595ffa2c4d0b401fda9786 |
|
MD5 | f2acf42a20b6ee439287a48de01fdc30 |
|
BLAKE2b-256 | 7c71217a6a78c3c7003af6c5a2ef0ec21c07cae5b24039d846389912c9da5f86 |