linting-and-formatting

Format, lint, and type-check Megatron-LM Python code with black, isort, ruff, pylint, and mypy.

17.4k|4.3k|Updated Mar 21, 2019
One-click install
npx skills add https://github.com/NVIDIA/Megatron-LM --skill linting-and-formatting-nvidia
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: linting-and-formatting
Source: https://github.com/NVIDIA/Megatron-LM/tree/main/skills/linting-and-formatting
Command: npx skills add https://github.com/NVIDIA/Megatron-LM --skill linting-and-formatting-nvidia

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps teams prevent style drift and CI failures by standardizing how Megatron-LM code is formatted, linted, and type-checked before changes are merged.

Core Features & Use Cases

  • Deterministic formatting via tools/autoformat.sh: Run in check mode to validate or in fix mode to apply consistent formatting across the codebase.
  • Multi-tool code quality enforcement: Uses ruff, black, isort, pylint, and mypy to catch style issues, import ordering problems, lint defects, and typing errors.
  • Practical developer workflow integration: Supports running a focused isort pass after editing imports and installing the same linting toolchain used by CI.

Quick Start

Run BASE_REF=main CHECK_ONLY=true SKIP_DOCS=false bash tools/autoformat.sh to verify that your branch meets formatting and lint/type standards before opening a PR.

Frequently Asked Questions about linting-and-formatting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix ruff, pylint, or mypy failures before opening a Megatron-LM pull request?▼

To fix ruff, pylint, or mypy failures before a Megatron-LM pull request, run tools/autoformat.sh to apply consistent formatting and resolve style, import ordering, and typing errors automatically.

What is the best way to format Python code to avoid CI style violations?▼

The best way to avoid CI style violations is using a multi-tool code quality enforcement approach with black, isort, and ruff to catch style issues and standardize formatting across the codebase.

How does tools/autoformat.sh work for checking and applying Python type-hint conventions?▼

The tools/autoformat.sh script works by running in check mode to validate formatting or fix mode to apply changes, using mypy and pylint to enforce Python type-hint conventions and lint standards.

Can I run only an isort pass to fix import ordering problems after editing imports?▼

Yes, you can run a focused isort pass after editing imports to specifically resolve import ordering problems, ensuring your code meets the repository-configured rules before submission.

Do I need to install the same linting toolchain used by CI to verify my branch?▼

Yes, you need to install the same linting toolchain used by CI, including black, isort, ruff, pylint, and mypy, to accurately verify that your branch meets formatting and type-checking standards.