linting-and-formatting

Enforce linting, formatting, and type-checking for Megatron-LM code changes.

Updated May 23, 2026
One-click install
npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill linting-and-formatting-yo-steven
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: linting-and-formatting
Source: https://github.com/yo-steven/skills-exploration-20260522/tree/main/skills/Megatron-Core/linting-and-formatting
Command: npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill linting-and-formatting-yo-steven

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Reduces time lost to style disagreements and CI failures by standardizing how Megatron-LM code is formatted, linted, and type-checked.

Core Features & Use Cases

  • Autoformat workflow: Run the repo’s formatter in check mode or fix mode using tools invoked by tools/autoformat.sh (black, isort, pylint, ruff, mypy).
  • Import ordering discipline: Ensure import changes are followed by isort to keep diffs clean and consistent.
  • Consistent dev environment: Install the same linting toolchain via the linting group in the container.
  • Team code style rules: Enforce type hints on public APIs, Google-style docstrings, Python naming conventions, 119-character line length, and avoid bare except.

Quick Start

Run BASE_REF=main CHECK_ONLY=true SKIP_DOCS=false bash tools/autoformat.sh to verify formatting and linting without applying changes.

Frequently Asked Questions about linting-and-formatting

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

FAQPage Schema
How do I run Python linting and formatting checks before submitting a PR?

Run Python linting and formatting checks before a PR by executing tools/autoformat.sh with black, isort, ruff, pylint, and mypy in check mode. Use BASE_REF=main CHECK_ONLY=true bash tools/autoformat.sh to verify style and type compliance without applying changes.

What code style rules are enforced for Megatron-LM patches?

Code style rules for Megatron-LM patches enforce public type hints, Google-style docstrings, Python naming conventions, a 119-character line length, and a strict no-bare-except policy. Import ordering is standardized by isort to keep diffs clean.

Why does my pull request fail CI checks due to style violations?

Pull requests fail CI checks due to style violations when code lacks proper formatting or type hints. Run the autoformat script to apply fixes using black, isort, ruff, pylint, and mypy, ensuring public type hints, Google docstrings, and 119-character line limits are satisfied.

Does the Megatron-LM autoformat script support checking without modifying files?

The Megatron-LM autoformat script supports checking without modifying files by setting CHECK_ONLY=true. This runs black, isort, ruff, pylint, and mypy in verification mode to report style violations without applying automatic fixes to your Python modules.

How do I install the correct linting toolchain for Megatron-LM?

Install the correct linting toolchain for Megatron-LM by using the linting group in the container. This ensures you have the exact black, isort, ruff, pylint, and mypy versions required to enforce repo-specific code style constraints before submitting patches.

How do I fix import ordering violations in my Python modules?

Fix import ordering violations in Python modules by running isort via the autoformat script. This tool enforces consistent import sorting across modules, keeping diffs clean and resolving CI failures related to import style violations.