Skip to content

Repository files navigation

Nob.py

Python version PyPI version License: MIT Read the wiki OS GitHub profile

Reasonable defaults for Click CLI applications with rich logging...
... and additional goodies.

  1. Installation
  2. Usage
  3. Contributing

Installation

uv add nob.py

Or:

pip install nob.py
Install from GitHub
uv add git+https://github.com/ThomasByr/nob.py --branch main

or lock a specific version:

uv add git+https://github.com/ThomasByr/nob.py --tag v0.1.3
Or if you are using pip
pip install git+https://github.com/ThomasByr/nob.py@main

You may directly also use @ with a tag, for example:

pip install git+https://github.com/ThomasByr/nob.py@v0.1.3
Available extras
  • ipc - for inter-process communication with posix_ipc (Linux and MacOS only).

Usage

Note

Get more usage examples in the Wiki.

from nob import cli


@cli.cmd()
@cli.opt("--name", required=True, help="Greet someone.")
def hello(lg: cli.Logger, name: str):
    lg.info("Hello %s", name)


if __name__ == "__main__":
    hello()

run with:

uv run <file.py> --name "Eric Norbert"

Replace uv run with python once your environment is activated - if you don't use uv.

Contributing

Important

Sign your commits.

Pre-requisites

  1. Install uv if you haven't already (or run uv self update):

    Linux Bash
    curl -LsSf https://astral.sh/uv/install.sh | sh

    or

    wget -qO- --content-disposition https://astral.sh/uv/install.sh | sh
    Windows Powershell
    powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  2. Install just:

    With uv
    uv tool install rust-just
    Or if you have cargo

    This way you can also install just-lsp.

    cargo install --locked just just-lsp

Useful just recipes

List all available recipes
just
Sync the codebase dependencies

Without explicit --all-extras syncing, some recipes will not evaluate on optional dependencies and functionalities.
The sync recipe will also update the dependencies if possible.

just sync
Before committing

We (I) work with ruff, ty and pytest.

just format check ty test
Release a new version

This recipe uses release-it. You will need a working npx installation.

Install fnm with cargo
cargo install fnm --locked
fnm install --lts
fnm use --lts
just release

Tip

Install pre-commit hooks: just pc-install.
To keep hooks somewhat fast enough, they will only check (not forcibly fix) for typing and formatting.

Releases

Contributors

Languages