Automate Python project setup and development tasks that are otherwise performed manually.
usethis
knows about popular Python tools, workflows and frameworks, and knows how they interact. It can declaratively add and remove tools, configure them, and set up the project for you in a way that won't break your existing configuration and it will make the necessary adjustments to your project configuration files.
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.
Tip
usethis
is great for fresh projects using uv, but also supports updating existing projects. However, this should be considered experimental. If you encounter problems or have feedback, please open an issue.
- π§° 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.
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.5.29 (run uv version
to check, and uv self update
to upgrade).
Tip
At the moment, usethis
assumes you will have uv installed in some circumstances. Support for projects that don't use uv is planned for late 2025.
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
To use Ruff on a fresh project, run:
$ uvx usethis tool ruff
β Writing 'pyproject.toml'.
β 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'.
β Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.
β Run 'uv run ruff format' to run the Ruff formatter.
To use pytest, run:
$ uvx usethis tool pytest
β Adding dependency 'pytest' to the 'test' group in 'pyproject.toml'.
β Adding pytest config to 'pyproject.toml'.
β Selecting Ruff rule 'PT' in 'pyproject.toml'.
β Creating '/tests'.
β Writing '/tests/conftest.py'.
β 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.
To configure Bitbucket pipelines, run:
$ uvx usethis ci bitbucket
β Writing 'bitbucket-pipelines.yml'.
β Adding cache 'uv' definition to 'bitbucket-pipelines.yml'.
β Adding 'Run Ruff' to default pipeline in 'bitbucket-pipelines.yml'.
β Adding 'Test on 3.12' to default pipeline in 'bitbucket-pipelines.yml'.
β Adding 'Test on 3.13' to default pipeline in 'bitbucket-pipelines.yml'.
β Run your pipeline via the Bitbucket website.
Add a new tool to a Python project, including:
- declared & installed dependencies with
uv add
, - relevant
pyproject.toml
configuration, - any other relevant directories or tool-bespoke configuration files, and
.pre-commit-config.yaml
configuration if usingpre-commit
.
usethis tool codespell
- Use the codespell spellchecker: detect common spelling mistakes.usethis tool deptry
- Use the deptry linter: avoid missing or superfluous dependency declarations.usethis tool import-linter
- Use Import Linter: enforce a self-imposed architecture on imports.usethis tool pre-commit
- Use the pre-commit framework to manage and maintain pre-commit hooks.usethis tool pyproject-fmt
- Use the pyproject-fmt linter: opinionated formatting of 'pyproject.toml' files.usethis tool ruff
- Use Ruff: an extremely fast Python linter and code formatter.
usethis tool coverage
- Use coverage: a code coverage measurement tool.usethis tool pytest
- Use the pytest testing framework.
usethis tool pyproject.toml
- Use a pyproject.toml file to configure the project.usethis tool requirements.txt
- Use a requirements.txt file exported from the uv lockfile.
Supported options:
--remove
to remove the tool instead of adding it--how
to only print how to use the tool, with no other side effects--offline
to disable network access and rely on caches--frozen
to leave the virtual environment and lockfile unchanged--quiet
to suppress output
Add Continuous Integration pipelines to the project.
Currently supported platforms:
usethis ci bitbcuket
Supported options:
--remove
to remove the CI configuration instead of adding it--offline
to disable network access and rely on caches--quiet
to suppress output
Add badges to README.md.
Currently supported badges:
usethis badge pre-commit
usethis badge pypi
usethis badge ruff
usethis badge usethis
usethis badge uv
Supported options:
--remove
to remove the badge instead of adding it--offline
to disable network access and rely on caches--quiet
to suppress output
Add (or manage configuration) of Ruff and Deptry rules in pyproject.toml
.
Example:
usethis rule RUF001
Supported options:
--remove
to remove the rule selection or ignore status.--ignore
to add the rule to the ignore list (or remove it if --remove is specified).--offline
to disable network access and rely on caches--quiet
to suppress output
Set a docstring style convention for the project, and enforce it with Ruff.
Currently supported docstring styles:
usethis docstyle numpy
usethis docstyle google
usethis docstyle pep257
Supported options:
--quiet
to suppress output
Add a README.md file to the project.
Supported options:
--quiet
to suppress output--badges
to also add badges to the README.md file
Set new author information for the project.
Required options:
--name
for the new author's name
Other supported options:
--email
to set the author email address--overwrite
to overwrite all existing author information--quiet
to suppress output
Display a table of all available tools and their current usage status.
Display the current version of usethis.
Show a piece of information about the project.
Currently supported subcommands:
usethis show name
to show the name of the project.usethis show sonarqube
to show appropriate contents of asonar-projects.properties
file for SonarQube analysis.
Display or open the PyPI landing page associated with another project.
Example:
usethis browse pypi numpy
Supported options:
--browser
to open the link in the browser automatically.
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 which works with Copier, or this template which works with Cookiecutter.
Tip
You can still use usethis as a part of a templates using hooks for Cookiecutter and tasks for Copier.
One of usethis's strengths is that it can update existing configuration. 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.
Major features planned for later in 2025 are:
- Support for users who aren't using uv, e.g. poetry users,
- Support for automated GitHub Actions workflows (#57),
- Support for a typechecker (likely Pyright, #121), and
- Support for documentation pages (likely using mkdocs, #188).
Other features are tracked in the GitHub Issues page.
See the CONTRIBUTING.md file.
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.