Skip to content

This repository contains configurations to set up a Python development environment using VSCode's Dev Container feature. The environment includes uv and Ruff.

License

Notifications You must be signed in to change notification settings

arrowkato/python-uv

 
 

Repository files navigation

VSCode Dev Container: Python Development with uv and Ruff

uv Ruff

Versions

Ruff Test Docker

Overview

This repository contains configurations to set up a Python development environment using VSCode's Dev Container feature. The environment includes uv, and Ruff.

demo

If the Ruff format does not work, try reloading the VS Code window. Specifically, you can solve this problem by following the steps below.

  1. Type ⌘+⇧+P to open the command palette
  2. Type Developer: Reload Window in the command palette to reload the window

Contents

Branches

Dev Container

GitHub Actions

  • docker.yml
    • Workflow to check if you can build with Docker
  • test.yml
    • Workflow to check if all the described tests can be passed with pytest
  • ruff.yml
    • Workflow to check if you can go through Formatter and Linter with Ruff

Ruff

Ruff can be used to replace Flake8, Black, isort, pydocstyle, pyupgrade, autoflake, etc., and yet run tens to hundreds of times faster than the individual tools.

To change the configuration, it is necessary to rewrite ruff.toml, and it is recommended to set it to ignore conflicts such as the following:

ignore = [
    "COM812", "COM819",
    "D100", "D203", "D213", "D300",
    "E111", "E114", "E117",
    "ISC001", "ISC002",
    "Q000", "Q001", "Q002", "Q003",
    "W191",
]

pre-commit

The .pre-commit-config.yaml file can contain scripts to be executed before commit.

# Python Formatter
uv run ruff format .

# Python Linter
uv run ruff check . --fix

# Docker Linter
hodolint Dockerfile

Appendix

Install libraries

Only sync based on the production lockfile (requirements.lock) instead of the development lockfile (requirements-dev.lock).

# Install also include develop dependencies
uv sync

# If you do not want dev dependencies to be installed
uv sync --no-dev

# Use the add command to add dependencies to your project
uv add {libraries}

The structure of this repository

.
├── .devcontainer
│   ├── devcontainer.json
│   └── Dockerfile
├── Dockerfile
├── .github
│   ├── actions
│   │   └── setup-python-with-uv
│   │       └── action.yml
│   ├── dependabot.yml
│   └── workflows
│       ├── docker.yml
│       ├── ruff.yml
│       └── test.yml
├── .gitignore
├── LICENSE
├── .pre-commit-config.yaml
├── pyproject.toml
├── .python-version
├── README.md
├── requirements-dev.lock
├── requirements.lock
├── ruff.toml
└── .vscode
    ├── extensions.json
    └── settings.json

About

This repository contains configurations to set up a Python development environment using VSCode's Dev Container feature. The environment includes uv and Ruff.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 54.3%
  • Dockerfile 45.7%