Automate Python project setup and development tasks that are otherwise performed manually.
Project description
usethis
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.
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.
๐งญ Getting Started
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
๐ฅ๏ธ Command Line Interface
Start a New Project
usethis initโ Initialize a new project with recommended defaults.
Manage Tooling
usethis formatโ Add/Configure recommended formatters (namely, Ruff and pyproject-fmt).usethis lintโ Add/Configure recommended linters (namely, Ruff and deptry).usethis spellcheckโ Add/Configure recommended spellcheckers (namely, codespell).usethis testโ Add/Configure a recommended testing framework (namely, pytest).usethis ciโ Add/Configure a recommended CI service.usethis toolโ Add/Configure specific tools individually.
Manage Configuration
usethis authorโ Set new author information for the project.usethis docstyleโ Set new author information for the project.usethis ruleโ Set a docstring style convention for the project, and enforce it with Ruff.usethis statusโ Set the development status of the project (via trove classifiers).
Manage README
usethis badgeโ Set new author information for the project.usethis readmeโ Add badges to the README file.
Information
usethis listโ Display a table of all available tools and their current usage status.usethis versionโ Display the current version of usethis.usethis browse pypiโ Display or open the PyPI landing page associated with another project.usethis showโ Show a specific piece of information about the project.
๐ก Example Usage
To start a new project from scratch with a complete set of recommended tooling, run:
$ uvx usethis init
โ Writing 'pyproject.toml' and initializing project.
โ Writing 'README.md'.
โ Populate 'README.md' to help users understand the project.
โ Adding recommended linters.
โ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.
โ Run 'uv run deptry src' to run deptry.
โ Adding recommended formatters.
โ Run 'uv run ruff format' to run the Ruff formatter.
โ Run 'uv run pyproject-fmt pyproject.toml' to run pyproject-fmt.
โ Adding recommended spellcheckers.
โ Run 'uv run codespell' to run the Codespell spellchecker.
โ Adding recommended test frameworks.
โ 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 use 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'.
โ 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.
๐ฅ๏ธ Command Reference
usethis init
Initialize a new Python project with recommended defaults, including:
- a
pyproject.tomlfile and relevant configuration, - recommended linters, formatters, spellcheckers, and test frameworks (all opt-out),
- docstring style enforcement (opt-in),
- the pre-commit framework (opt-in),
- CI services (opt-in),
- declared & installed dependencies via
uv add, and - any other relevant directories or tool-bespoke configuration files.
Supported options:
--formatto add recommended formatters (default; or--no-formatto opt-out)--lintto add recommended linters (default; or--no-lintto opt-out)--spellcheckto add a recommended spellchecker (default; or--no-spellcheckto opt-out)--testto add a recommended testing framework (default; or--no-testto opt-out)--pre-committo add the pre-commit framework for git hooks (but the default is--no-pre-commit)--cito add a CI service configuration Possible values:bitbucketfor Bitbucket Pipelines
--docstyleto set a docstring style convention for the project Possible values:numpyfor NumPy docstring stylegooglefor Google docstring stylepep257for PEP 257 docstring style
--statusto set the development status of the project. Defaults toplanning. Possible values:planningor1for "Development Status :: 1 - Planning"pre-alphaor2for "Development Status :: 2 - Pre-Alpha"alphaor3for "Development Status :: 3 - Alpha"betaor4for "Development Status :: 4 - Beta"productionor5for "Development Status :: 5 - Production/Stable"matureor6for "Development Status :: 6 - Mature"inactiveor7for "Development Status :: 7 - Inactive"
--offlineto disable network access and rely on caches--quietto suppress output--frozento leave the virtual environment and lockfile unchanged (i.e. do not install dependencies, nor update lockfiles)
usethis format
Add recommended formatters to the project (namely, Ruff and pyproject-fmt), including:
- declared & installed dependencies via
uv add, - relevant
pyproject.tomlconfiguration, and - any other relevant directories or tool-bespoke configuration files.
Note if pyproject.toml is not present, it will be created, since this is required for declaring dependencies via uv add.
Supported options:
--removeto remove the tool instead of adding it--howto only print how to use the tool, with no other side effects--offlineto disable network access and rely on caches--frozento leave the virtual environment and lockfile unchanged--quietto suppress output
See usethis tool for more information.
usethis lint
Add recommended linters to the project (namely, Ruff and deptry), including:
- declared & installed dependencies with
uv add, - relevant
pyproject.tomlconfiguration, and - any other relevant directories or tool-bespoke configuration files.
Note if pyproject.toml is not present, it will be created, since this is required for declaring dependencies with uv add.
Supported options:
--removeto remove the tool instead of adding it--howto only print how to use the tool, with no other side effects--offlineto disable network access and rely on caches--frozento leave the virtual environment and lockfile unchanged--quietto suppress output
See usethis tool for more information.
usethis spellcheck
Add a recommended spellchecker to the project (namely, codespell), including:
- declared & installed dependencies with
uv add, - relevant
pyproject.tomlconfiguration, and - any other relevant directories or tool-bespoke configuration files.
Note if pyproject.toml is not present, it will be created, since this is required for declaring dependencies with uv add.
Supported options:
--removeto remove the tool instead of adding it--howto only print how to use the tool, with no other side effects--offlineto disable network access and rely on caches--frozento leave the virtual environment and lockfile unchanged--quietto suppress output
See usethis tool for more information.
usethis test
Add a recommended testing framework to the project (namely pytest), including:
- declared & installed dependencies with
uv add, - relevant
pyproject.tomlconfiguration, and - any other relevant directories or tool-bespoke configuration files.
Note if pyproject.toml is not present, it will be created, since this is required for declaring dependencies with uv add.
Supported options:
--removeto remove the tool instead of adding it--howto only print how to use the tool, with no other side effects--offlineto disable network access and rely on caches--frozento leave the virtual environment and lockfile unchanged--quietto suppress output
See usethis tool for more information.
usethis tool
Add a new tool to a Python project, including:
- declared & installed dependencies with
uv add, - relevant
pyproject.tomlconfiguration, - any other relevant directories or tool-bespoke configuration files, and
.pre-commit-config.yamlconfiguration if usingpre-commit.
Note if pyproject.toml is not present, it will be created, since this is required for
declaring dependencies with uv add.
Code Quality Tools
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.
Testing
usethis tool coverage.py- Use Coverage.py: a code coverage measurement tool.usethis tool pytest- Use the pytest testing framework.
Configuration Files
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:
--removeto remove the tool instead of adding it--howto only print how to use the tool, with no other side effects--offlineto disable network access and rely on caches--frozento leave the virtual environment and lockfile unchanged--quietto suppress output
For usethis tool ruff, in addition to the above options, you can also specify:
--linterto add or remove specifically the linter component of Ruff (default; or--no-linterto opt-out)--formatterto add or remove specifically the formatter component of Ruff (default; or--no-formatterto opt-out)
usethis ci
Add Continuous Integration pipelines to the project.
Currently supported platforms:
usethis ci bitbcuket- Use Bitbucket Pipelines: a CI/CD service for Bitbucket.
Supported options:
--removeto remove the CI configuration instead of adding it--offlineto disable network access and rely on caches--quietto suppress output
usethis badge
Add badges to the README file.
Currently supported badges:
usethis badge pre-commit-usethis badge pypi-usethis badge ruff-usethis badge usethis-usethis badge uv-
Supported options:
--showto show the badge URL instead of adding (or removing) it--removeto remove the badge instead of adding it--offlineto disable network access and rely on caches--quietto suppress output
usethis readme
Add a README.md file to the project.
Supported options:
--quietto suppress output--badgesto also add badges to the README.md file
usethis author
Set new author information for the project.
Required options:
--namefor the new author's name
Other supported options:
--emailto set the author email address--overwriteto overwrite all existing author information--quietto suppress output
usethis docstyle <style>
Set a docstring style convention for the project, and enforce it with Ruff.
Defaults to the Google docstring style.
Possible style options:
numpyfor NumPy docstring stylegooglefor Google docstring stylepep257for PEP 257 docstring style
Example:
usethis docstyle google
Supported options:
--quietto suppress output
usethis rule <rulecode>
Add (or manage configuration) of Ruff and Deptry rules in pyproject.toml.
See the Ruff documentation for a list of available rules, and the Deptry documentation for a list of available rules.
Example:
usethis rule RUF001
Supported options:
--removeto remove the rule selection or ignore status.--ignoreto add the rule to the ignore list (or remove it if --remove is specified).--offlineto disable network access and rely on caches--quietto suppress output
usethis status <status>
Set the development status of the project via trove classifiers.
Possible values (required):
usethis status planningorusethis status 1for "Development Status :: 1 - Planning"usethis status pre-alphaorusethis status 2for "Development Status :: 2 - Pre-Alpha"usethis status alphaorusethis status 3for "Development Status :: 3 - Alpha"usethis status betaorusethis status 4for "Development Status :: 4 - Beta"usethis status productionorusethis status 5for "Development Status :: 5 - Production/Stable"usethis status matureorusethis status 6for "Development Status :: 6 - Mature"usethis status inactiveorusethis status 7for "Development Status :: 7 - Inactive"
Supported options:
--quietto suppress output--badgesto add an associated badge to the README file
usethis list
Display a table of all available tools and their current usage status.
usethis version
Display the current version of usethis.
usethis show
Show a piece of information about the project.
Currently supported subcommands:
usethis show nameto show the name of the project.usethis show sonarqubeto show appropriate contents of asonar-projects.propertiesfile for SonarQube analysis.
usethis browse pypi <package>
Display or open the PyPI landing page associated with another project.
Example:
usethis browse pypi numpy
Supported options:
--browserto open the link in the browser automatically.
๐ 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 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.
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.
๐ Development
Roadmap
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.
Contributing
See the CONTRIBUTING.md file.
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
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
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 usethis-0.14.0.tar.gz.
File metadata
- Download URL: usethis-0.14.0.tar.gz
- Upload date:
- Size: 302.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8f0d213059b2e5094b33d26408152fad04e308e0d5bbc81c70f20072ec4fd50
|
|
| MD5 |
8310081e7b0c9dc170354da3a182c179
|
|
| BLAKE2b-256 |
5bd106b2bb8ad646abad458c5178f357d6e2ff6411a16e6df3e659b91d837bfe
|
File details
Details for the file usethis-0.14.0-py3-none-any.whl.
File metadata
- Download URL: usethis-0.14.0-py3-none-any.whl
- Upload date:
- Size: 140.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
224b1b0e9bae0708b3cf55654d11104f17a9e7ac42420a9b153e33f21e9fbaad
|
|
| MD5 |
e83b1dad56795841e378df3be817ce0e
|
|
| BLAKE2b-256 |
fb9a9d44eba6486d6973fd25df59301f15f3d973053af9142f1bcd9409b8ebae
|