mcore-linting-and-formatting
NVIDIA/skills
Analiza y formatea el código de Python para Megatron-LM utilizando ruff, black, isort, pylint y mypy, con comandos para la autoformatación y el ordenamiento de importaciones.
...Expandir todoAnálisis estático y formateo
Ejecutar el formateador
Ejecute antes de abrir una solicitud de extracción (PR):
# Modo de comprobación (no se aplican cambios)
BASE_REF=main CHECK_ONLY=true SKIP_DOCS=false bash tools/autoformat.sh
# Modo de corrección
BASE_REF=main CHECK_ONLY=false bash tools/autoformat.sh
Herramientas invocadas: black, isort, pylint, ruff, mypy.
Orden de importaciones
Después de editar las importaciones en cualquier archivo Python, ejecute siempre uv run isort en dichos archivos antes de confirmar los cambios:
uv run isort <file1>.py <file2>.py
</file2></file1>Configuración del grupo de análisis estático
Dentro del contenedor:
uv sync --locked --only-group linting
Esto instala ruff, black, isort, pylint, las mismas herramientas utilizadas por tools/autoformat.sh y el trabajo linting de la integración continua (CI).
Reglas de estilo de código
- Indicaciones de tipo: obligatorias en todas las funciones de la API pública. Utilice
X | None, noOptional[X]. - Documentación de docstrings: estilo Google en todas las clases y funciones públicas.
- Nomenclatura: siga las convenciones de Python —
snake_casepara funciones y variables,PascalCasepara clases. - Longitud de línea: 119 caracteres (configurado en
pyproject.toml). - Sin
exceptsin especificar: capture siempre tipos de excepciones específicos.
---
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.
Instalar mcore-linting-and-formatting
Descarga y extrae los archivos de habilidades en tu directorio .claude/skills/.
Descargar ZIPClona el repositorio y copia los archivos de la habilidad a tu proyecto.
git clone https://github.com/NVIDIA/skills/tree/main/skills/mcore-linting-and-formatting # Copy SKILL.md to your .claude/skills/ directory
Copiar





Hogar
