Skip to main content

Automatically manage Python tooling and configuration: linters, formatters, and more. A CLI for declaratively configuring your Python projects following best practices.

Project description

usethis logo

usethis

usethis PyPI Version PyPI License PyPI Supported Versions Docs

Automatically manage Python tooling and configuration: linters, formatters, and more. A CLI for declaratively configuring your Python projects following best practices.

usethis is a command-line interface to automate the configuration of popular Python tools, workflows, and frameworks. You can use it to declaratively add, remove, and configure tools in an existing project, as well as set up a new project from scratch. It won't break your existing configuration, and ensures all tools work together smoothly.

usethis gives detailed messages about what it is doing (and what you need to do next).

  • Output beginning with represents a task which usethis has automated.
  • Output beginning with represents a task which you need to perform manually.
  • Output beginning with gives hints and tips.

Inspired by an R package of the same name, this package brings a similar experience to the Python ecosystem as a CLI tool.

Highlights

  • 🧰 First-class support for state-of-the-practice tooling: uv, Ruff, pytest, pre-commit, and many more.
  • 🤖 Automatically add and remove tools: declare, install, and configure in one step.
  • 🧠 Powerful knowledge of how different tools interact and sensible defaults.
  • 🔄 Update existing configuration files automatically.
  • 📢 Fully declarative project configuration.
  • ⚡ Get started on a new Python project or a new workflow in seconds.

🧭 Installation

First, it is strongly recommended you install the uv package manager: this is a simple, documented process. If you're already using uv, make sure you're using at least version v0.9.9 (run uv --version to check, and uv self update to upgrade).

You can install usethis directly into the project environment:

# With uv
$ uv add --dev usethis

# With pip
$ pip install usethis

Alternatively, you can also run usethis commands in isolation, using uvx or pipx. For example, to add Ruff to the project:

# With uv
$ uvx usethis tool ruff

# With pipx
$ pipx run usethis tool ruff

📜 Documentation

The usethis documentation is available at usethis.readthedocs.io.

Additionally, the command line reference documentation can be viewed with usethis --help.

🖥️ Command Line Interface

Start a New Project

  • usethis init — Initialize a new project with recommended defaults.

Manage Tooling

Manage Configuration

Manage the README

Information

💡 Example Usage

Starting a new project

To start a new project from scratch with a complete set of recommended tooling, simply run the uvx usethis init command.

Configuring individual tools

You can also configure individual tools one-by-one. For example, to add Ruff on an existing project, run:

$ uvx usethis tool ruff
✔ Adding dependency 'ruff' to the 'dev' group in 'pyproject.toml'.
✔ Adding Ruff config to 'pyproject.toml'.
✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'.
✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'.
✔ Running the Ruff formatter.
☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.
☐ Run 'uv run ruff format' to run the Ruff formatter.

For a detailed breakdown of what each line of the output means, there is a detailed explanation available.

As another example, to use pytest, run:

$ uvx usethis tool pytest
✔ Adding dependency 'pytest' to the 'test' group in 'pyproject.toml'.
✔ Adding pytest config to 'pyproject.toml'.
✔ Creating '/tests'.
✔ Writing '/tests/conftest.py'.
✔ Writing '/tests/test_example.py'.
✔ Selecting Ruff rule 'PT' in 'pyproject.toml'.
☐ Add test files to the '/tests' directory with the format 'test_*.py'.
☐ Add test functions with the format 'test_*()'.
☐ Run 'uv run pytest' to run the tests.

See the CLI Reference for a full list of available commands.

📚 Similar Projects

Not sure if usethis is the exact fit for your project?

The closest match to usethis is PyScaffold. It provides a Command Line Interface to automate the creation of a project from a sensible templated structure.

You could also consider your own hard-coded template. Templating tools such as Cookiecutter and Copier allow you to create static templates with fixed configuration you can use across multiple projects. However, it's not always obvious which template you should use, and many do not use state-of-practice tooling such as pyproject.toml. Also, sometimes a template can overwhelm you with too many unfamiliar tools.

You could consider this template or this one, which work with Copier, or this template which works with Cookiecutter.

You can still use usethis as part of templates using hooks for Cookiecutter and tasks for Copier.

If you're using Cookiecutter, then you can update to a latest version of a template using a tool like cruft. Copier has inbuilt support for template updating. Another template-style option which provides updating is jaraco/skeleton, which is a specific, git-based template rather than a general templating system.

If you're not interested in templating automations, then configurator provides a list of useful tooling and configuration to consider for your Python projects. If you're adopting a specific framework like Django, FastAPI, Dagster, or Flask, this list gives options for initializing new projects via CLI. If you're looking for guidance on best practices for Python projects, the Scientific Python Library Development Guide is an excellent resource, including its repo-review tool.

🚀 Development

Commits since latest release GitHub Actions Status codecov CodSpeed uv Ruff Socket

Feature requests are tracked in the GitHub Issues page.

Contributing

See the CONTRIBUTING.md file.

Acknowledgements

Special thanks to the Posit team for creating the original usethis package for R, which inspired this project.

Additional thanks are due to the maintainers of the various tools which usethis integrates with, especially the people at Astral who created uv.

License

usethis is licensed under the MIT license (LICENSE or https://opensource.org/licenses/MIT)

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in usethis by you, as defined in the Apache License, Version 2.0, (https://www.apache.org/licenses/LICENSE-2.0), shall be licensed under the MIT license, without any additional terms or conditions.

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

usethis-0.22.0.tar.gz (509.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

usethis-0.22.0-py3-none-any.whl (188.1 kB view details)

Uploaded Python 3

File details

Details for the file usethis-0.22.0.tar.gz.

File metadata

  • Download URL: usethis-0.22.0.tar.gz
  • Upload date:
  • Size: 509.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for usethis-0.22.0.tar.gz
Algorithm Hash digest
SHA256 1c29ef12ea4f0fc9d1920b7cfd9431c716dd88a57bfd2ad35a5acb5e1fcd6f95
MD5 96e3206a5c5955d99aa507f8a2c9eade
BLAKE2b-256 d945e22b7810355e5ba19d36f1c64f65f1d0609e9bf70388af4c83ac4d2888fc

See more details on using hashes here.

File details

Details for the file usethis-0.22.0-py3-none-any.whl.

File metadata

  • Download URL: usethis-0.22.0-py3-none-any.whl
  • Upload date:
  • Size: 188.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for usethis-0.22.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9663bed0b4521ab959c7f9067d35d4b643124bfe0c26b0eb9bd477d5a61d3a2
MD5 fdb51a546b6ab8dfb5caf7136e845550
BLAKE2b-256 536989cceb8f971d8598af6328730b46be5fade4eca5bb9d487af2a5e3648d7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page