About Devcontainer Python
Devcontainer Python is a Devcontainer-based template for setting up Python project environments. It is intended for developers who want a consistent, isolated workspace with example code, tests, and common quality tools.
Key features
- 01Python 3.11 development environment
- 02Preinstalled pytest, flake8, and black
- 03Docker-based isolated workspace
- 04Python syntax and design-pattern examples
- 05Included test cases
Use cases
- 01Start a Python project in a consistent environment
- 02Explore Python syntax and design patterns
- 03Run tests and check or format code
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEDevcontainer Python
このリポジトリは、Python プロジェクトの開発環境を簡単に構築できる Devcontainer を利用したテンプレートです。必要なツールや依存関係があらかじめ設定されており、一貫した開発環境を提供します。
特徴
- Python 3.11 を使用
- あらかじめインストールされているツール:
pytest(テストフレームワーク)flake8(コードリントツール)black(コードフォーマッタ)
- Devcontainer による一貫性のある開発環境
- Docker ベースの隔離された環境で、設定の一貫性を保証
- サンプルコードとリファレンス例の追加
- Python の基本的な文法やデザインパターンをカバー
- 詳細なテストケースを含む実装
はじめに
以下の手順で、この開発環境を利用できます。
-
このリポジトリをクローンします:
git clone https://github.com/tomohiroJin/devcontainer-python.git -b feature/add-reference cd devcontainer-python -
VS Code でプロジェクトを開きます:
code . -
Devcontainer でプロジェクトを再オープンするように求められたら、指示に従って再オープンします。
-
セットアップを確認するためにテストを実行します:
pytest
リファレンス
このプロジェクトには、基本的な Python の文法と主要なデザインパターンを学習・参照できるサンプルが含まれています。
使用方法
1. テストの実行
pytestを使用してプロジェクトのテストを実行します。以下のように、さまざまな方法でテストを実行できます。
すべてのテストを実行
pytest
特定のテストファイルを実行
特定のテストファイルのみを実行したい場合は、ファイルパスを指定します。
pytest tests/reference/basic/test_conditions.py
テストの進捗と詳細を確認
-v(verbose)オプションを使用して、各テストの詳細を確認できます。
pytest -v
特定のテストケースを実行
-kオプションを使って、名前に特定の文字列を含むテストケースを実行します。
pytest -k "fizzbuzz"
テスト中の出力を確認
テスト中のprintやログの出力を確認したい場合、-sオプションを使用します。
pytest -s
テスト結果をリポート形式で保存
pytest-htmlプラグインを使用して、HTML 形式のレポートを生成します。
pip install pytest-html
pytest --html=report.html
2. コード品質チェック
flake8を使用してコードの品質を確認します。以下のオプションを組み合わせることで、詳細な結果を得ることができます。
基本的なコードチェック
プロジェクト全体をチェックします。
flake8
最大行長を指定
Black と統一するために、最大行長を 88 文字に設定します(設定ファイルに記述しても OK)。
flake8 --max-line-length=88
特定のルールを無視
Black と矛盾するルール(例: E203, W503)を無視して実行します。
flake8 --ignore=E203,W503
特定のファイルのみをチェック
特定のファイルやディレクトリだけをチェックします。
flake8 src/fizzbuzz/fizzbuzz.py
コード内の TODO や FIXME を確認
--radarや--todoプラグインを使用して、TODO コメントを含む箇所を一覧表示します(プラグインのインストールが必要)。
pip install flake8-todo
flake8 --todo
3. コードのフォーマット
blackを使用してコードを自動整形します。
プロジェクト全体をフォーマット
プロジェクト内のすべての Python ファイルをフォーマットします。
black .
変更内容をプレビュー
--checkオプションを使用すると、フォーマットの提案内容だけを確認できます(実際の変更は行われません)。
black --check .
特定のファイルやディレクトリだけをフォーマット
特定の範囲だけを対象にする場合、パスを指定します。
black src/fizzbuzz/fizzbuzz.py
カスタマイズ:
.devcontainer/devcontainer.jsonファイルを編集することで、開発環境をカスタマイズできます。- 例えば、Python のバージョン変更や追加ツールのインストールが可能です。
ライセンス
このプロジェクトは MIT ライセンスの下で提供されています。
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.