Skip to content

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

License

Notifications You must be signed in to change notification settings

a5chin/python-poetry

Repository files navigation

VSCode Dev Container: Python Development with Poetry, pyenv, and Ruff

Poetry pyenv 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 Poetry, pyenv, and Ruff.

Contents

The following are the features.

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
ruff format .

# Python Linter
ruff check . --fix

# Docker Linter
hodolint Dockerfile

Install

Only install based on the production group instead of the development group (tool.poetry.group.dev.dependencies) in pyproject.toml.

# Install also include develop dependencies
poetry install

# If you do not want dev dependencies to be installed
poetry install --no-dev

Appendix

The structure of this repository

.
├── .devcontainer
│   ├── devcontainer.json
│   └── Dockerfile
├── Dockerfile
├── .github
│   └── workflows
│       ├── docker.yml
│       ├── ruff.yml
│       └── pytest.yml
├── .gitignore
├── LICENSE
├── poetry.lock
├── poetry.toml
├── .pre-commit-config.yaml
├── pyproject.toml
├── .python-version
├── README.md
├── 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 Poetry, pyenv, and Ruff.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published