Skip to main content

Automate Python project setup and development tasks that are otherwise performed manually.

Project description


usethis

usethis PyPI Version PyPI License PyPI Supported Versions uv CodSpeed codecov GitHub Actions Status

Automate Python project setup and development tasks that are otherwise performed manually.

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.

[!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.6.8 (run uv self version to check (if available, otherwise uv version), 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

Manage Configuration

Manage the README

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 documentation tools.
โ˜ Run 'uv run mkdocs build' to build the documentation.
โ˜ Run 'uv run mkdocs serve' to serve the documentation locally.
โœ” 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.
โ˜ Run 'uv run pytest --cov' to run your tests with Coverage.py.

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.toml file 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:

  • --doc to add recommended documentation tools (default; or --no-doc to opt-out)
  • --format to add recommended formatters (default; or --no-format to opt-out)
  • --lint to add recommended linters (default; or --no-lint to opt-out)
  • --spellcheck to add a recommended spellchecker (default; or --no-spellcheck to opt-out)
  • --test to add a recommended testing framework (default; or --no-test to opt-out)
  • --pre-commit to add the pre-commit framework for git hooks (but the default is --no-pre-commit)
  • --ci to add a CI service configuration Possible values:
  • --docstyle to set a docstring style convention for the project Possible values:
  • --status to set the development status of the project. Defaults to planning. Possible values:
    • planning or 1 for "Development Status :: 1 - Planning"
    • pre-alpha or 2 for "Development Status :: 2 - Pre-Alpha"
    • alpha or 3 for "Development Status :: 3 - Alpha"
    • beta or 4 for "Development Status :: 4 - Beta"
    • production or 5 for "Development Status :: 5 - Production/Stable"
    • mature or 6 for "Development Status :: 6 - Mature"
    • inactive or 7 for "Development Status :: 7 - Inactive"
  • --offline to disable network access and rely on caches
  • --quiet to suppress output
  • --frozen to leave the virtual environment and lockfile unchanged (i.e. do not install dependencies, nor update lockfiles)

usethis doc

Add recommended documentation tools to the project (namely, MkDocs), including:

  • declared & installed dependencies via uv add,
  • relevant pyproject.toml configuration, 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:

  • --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

See usethis tool for more information.

usethis format

Add recommended formatters to the project (namely, Ruff and pyproject-fmt), including:

  • declared & installed dependencies via uv add,
  • relevant pyproject.toml configuration, 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:

  • --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

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.toml configuration, 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:

  • --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

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.toml configuration, 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:

  • --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

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.toml configuration, 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:

  • --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

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.toml configuration,
  • any other relevant directories or tool-bespoke configuration files, and
  • .pre-commit-config.yaml configuration if using pre-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.

Documentation

  • usethis tool mkdocs - Use MkDocs: Generate project documentation sites with Markdown.

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:

  • --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

For usethis tool ruff, in addition to the above options, you can also specify:

  • --linter to add or remove specifically the linter component of Ruff (default; or --no-linter to opt-out)
  • --formatter to add or remove specifically the formatter component of Ruff (default; or --no-formatter to opt-out)

usethis ci

Add Continuous Integration pipelines to the project.

Currently supported platforms:

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
  • --frozen to leave the virtual environment and lockfile unchanged (i.e. do not install dependencies, nor update lockfiles)

usethis badge

Add badges to the README file.

Currently supported badges:

  • usethis badge pre-commit - pre-commit
  • usethis badge pypi - PyPI Version
  • usethis badge ruff - Ruff
  • usethis badge usethis - usethis
  • usethis badge uv - uv

Supported options:

  • --show to show the badge URL instead of adding (or removing) it
  • --remove to remove the badge instead of adding it
  • --offline to disable network access and rely on caches
  • --quiet to suppress output

usethis readme

Add a README.md file to the project.

Supported options:

  • --quiet to suppress output
  • --badges to also add badges to the README.md file

usethis author

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

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:

Example:

usethis docstyle google

Supported options:

  • --offline to disable network access and rely on caches
  • --quiet to suppress output
  • --frozen to leave the virtual environment and lockfile unchanged (i.e. do not install dependencies, nor update lockfiles)

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:

  • --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

usethis status <status>

Set the development status of the project via trove classifiers.

Possible values (required):

  • usethis status planning or usethis status 1 for "Development Status :: 1 - Planning"
  • usethis status pre-alpha or usethis status 2 for "Development Status :: 2 - Pre-Alpha"
  • usethis status alpha or usethis status 3 for "Development Status :: 3 - Alpha"
  • usethis status beta or usethis status 4 for "Development Status :: 4 - Beta"
  • usethis status production or usethis status 5 for "Development Status :: 5 - Production/Stable"
  • usethis status mature or usethis status 6 for "Development Status :: 6 - Mature"
  • usethis status inactive or usethis status 7 for "Development Status :: 7 - Inactive"

Supported options:

  • --quiet to suppress output
  • --badges to 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 name to show the name of the project.
  • usethis show sonarqube to show appropriate contents of a sonar-projects.properties file 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:

  • --browser to 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 or this one, which work 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

Commits since latest release

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), and
  • Support for a typechecker (likely Pyright, #121).

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


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.15.1.tar.gz (317.7 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.15.1-py3-none-any.whl (150.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: usethis-0.15.1.tar.gz
  • Upload date:
  • Size: 317.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.0

File hashes

Hashes for usethis-0.15.1.tar.gz
Algorithm Hash digest
SHA256 cc4f0fd4922e8004f23e7ac0d4dc04b5deee5d2215a41d093dd0191c24816844
MD5 60b5331f04ba63e869e89b76a882dbea
BLAKE2b-256 c62937da7338aca70f8fa904aa98e26a49ba560cae570e28fda9d8f5bd9fd3b9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: usethis-0.15.1-py3-none-any.whl
  • Upload date:
  • Size: 150.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.0

File hashes

Hashes for usethis-0.15.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e4f583c5d3549536922816a700e617c2f988be359ecf1b2dc31e2bc9b8b8e77d
MD5 dc611ebc24727b34863878c871a5bb1f
BLAKE2b-256 1f979e7a63ca16becb8e6bcab1ad0fd046435384ac58c05cfdd918498b07090d

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