オプション
家家 Skill 開発者ツール mcore-linting-and-formatting

mcore-linting-and-formatting

NVIDIA/skills NVIDIA/skills

ruff、black、isort、pylint、mypy を用いて Megatron-LM の Python コードのリンティングとフォーマットを行い、自動フォーマットおよびインポート順序付けのコマンドを提供する。

...すべて拡張します
0
更新された時間 2026年9月27日

リンティングとフォーマット

フォーマッターの実行

PR(プルリクエスト)の作成前に実行します:

# チェックモード(変更は適用されない)
BASE_REF=main CHECK_ONLY=true SKIP_DOCS=false bash tools/autoformat.sh

# 修正モード
BASE_REF=main CHECK_ONLY=false bash tools/autoformat.sh

呼び出されるツール:black、isort、pylint、ruff、mypy。

インポートの順序

Python ファイル内のインポートを編集した後、コミットする前に必ずそのファイルに対して uv run isort を実行してください:

uv run isort <file1>.py <file2>.py
</file2></file1>

リンティンググループの設定

コンテナ内:

uv sync --locked --only-group linting

これにより、tools/autoformat.sh および CI の linting ジョブで使用されるのと同じツールである ruff、black、isort、pylint がインストールされます。

コードスタイルルール

  • 型ヒント:すべての公開 API 関数に必須です。Optional[X] ではなく X | None を使用してください。
  • ドキュメント文字列:すべての公開クラスおよび関数に Google スタイルを使用します。
  • 命名規則:Python の慣習に従ってください。関数および変数は snake_case、クラスは PascalCase とします。
  • 行長:119 文字(pyproject.toml で設定済み)。
  • 裸の except は禁止:必ず特定の例外タイプをキャッチしてください。
GitHubで見る
---
name: mcore-linting-and-formatting
description: Lint and format Python code for Megatron-LM using ruff, black, isort, pylint, and mypy, with commands for autoformatting and import ordering.
license: Apache-2.0
---

# Linting and Formatting

---

## Running the Formatter

Run before opening a PR:

```bash
# Check mode (no changes applied)
BASE_REF=main CHECK_ONLY=true SKIP_DOCS=false bash tools/autoformat.sh

# Fix mode
BASE_REF=main CHECK_ONLY=false bash tools/autoformat.sh
```

Tools invoked: `black`, `isort`, `pylint`, `ruff`, `mypy`.

---

## Import Ordering

After editing imports in any Python files, always run `uv run isort` on those
files before committing:

```bash
uv run isort <file1>.py <file2>.py
```

---

## Setting Up the Linting Group

Inside the container:

```bash
uv sync --locked --only-group linting
```

This installs `ruff`, `black`, `isort`, `pylint` — the same tools used by
`tools/autoformat.sh` and CI's `linting` job.

---

## Code Style Rules

- **Type hints**: required on all public API functions. Use `X | None`, not `Optional[X]`.
- **Docstrings**: Google-style on all public classes and functions.
- **Naming**: follow Python conventions — `snake_case` for functions and variables, `PascalCase` for classes.
- **Line length**: 119 characters (configured in `pyproject.toml`).
- **No bare `except`**: always catch specific exception types.

すべてのファイル

5件のファイル

mcore-linting-and-formattingをインストール

スキルファイルをダウンロードして .claude/skills/ ディレクトリに展開してください。

ZIPをダウンロード

リポジトリをクローンし、スキルファイルをプロジェクトにコピーしてください。

git clone https://github.com/NVIDIA/skills/tree/main/skills/mcore-linting-and-formatting # Copy SKILL.md to your .claude/skills/ directory

コピー コピー
クイックセットアップ: スキルフォルダを .claude/skills/ にコピーしてください。Claude はそのスキルを自動的に検出し、使用します。
リポジトリ NVIDIA/skills

関連スキル

algorithmic-art
更新された時間 2026年8月27日
systematic-debugging
更新された時間 2026年9月3日
tech-debt-tracker
更新された時間 2026年8月29日
continual-learning
更新された時間 2026年9月10日
OR