Option
HeimHeim Skill Entwicklertools mcore-linting-and-formatting

mcore-linting-and-formatting

NVIDIA/skills NVIDIA/skills

Linten und formatieren Sie Python-Code für Megatron-LM mit ruff, black, isort, pylint und mypy, einschließlich Befehlen zur automatischen Formatierung und Importreihenfolge.

...Alle erweitern
0
Zeit aktualisiert 27. September 2026

Linten und Formatieren

Den Formatter ausführen

Vor dem Öffnen eines PR ausführen:

# Prüfmodus (keine Änderungen werden angewendet)
BASE_REF=main CHECK_ONLY=true SKIP_DOCS=false bash tools/autoformat.sh

# Korrekturmodus
BASE_REF=main CHECK_ONLY=false bash tools/autoformat.sh

Aufgerufene Tools: black, isort, pylint, ruff, mypy.

Import-Reihenfolge

Nach dem Bearbeiten von Imports in beliebigen Python-Dateien ist vor dem Commit stets uv run isort für diese Dateien auszuführen:

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

Einrichtung der Linting-Gruppe

Innerhalb des Containers:

uv sync --locked --only-group linting

Dadurch werden ruff, black, isort, pylint installiert — dieselben Tools, die auch von tools/autoformat.sh und dem linting-Job der CI verwendet werden.

Code-Stil-Regeln

  • Typangaben: erforderlich für alle öffentlichen API-Funktionen. Verwenden Sie X | None, nicht Optional[X].
  • Docstrings: Google-Stil für alle öffentlichen Klassen und Funktionen.
  • Namensgebung: folgen Sie den Python-Konventionen — snake_case für Funktionen und Variablen, PascalCase für Klassen.
  • Zeilenlänge: 119 Zeichen (konfiguriert in pyproject.toml).
  • Keine nackten except-Blöcke: fangen Sie stets spezifische Ausnahmetypen ab.
Auf GitHub ansehen
---
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.

mcore-linting-and-formatting installieren

Laden Sie die Skill-Dateien herunter und extrahieren Sie diese in Ihr .claude/skills/-Verzeichnis.

ZIP herunterladen

Klonen Sie das Repository und kopieren Sie die Skill-Dateien in Ihr Projekt.

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

Kopieren Kopieren
Schnelle Einrichtung: Kopieren Sie den Ordner „Skill“ nach .claude/skills/. Claude erkennt und verwendet den Skill automatisch.
Repository NVIDIA/skills

Ähnliche Skills

algorithmic-art
Zeit aktualisiert 27. August 2026
systematic-debugging
Zeit aktualisiert 3. September 2026
tech-debt-tracker
Zeit aktualisiert 29. August 2026
continual-learning
Zeit aktualisiert 10. September 2026
OR