mcore-linting-and-formatting
NVIDIA/skills
ruff, black, isort, pylint, mypy를 사용하여 Megatron-LM의 Python 코드의 린팅 및 포매팅을 수행하며, 자동 포매팅 및 import 순서 명령어를 포함합니다.
...모든 것을 확장하십시오린팅 및 포매팅
포매터 실행
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
이 명령어는 ruff, black, isort, pylint를 설치합니다. 이는 tools/autoformat.sh와 CI의 linting 작업에서 사용되는 동일한 도구들입니다.
코드 스타일 규칙
- 타입 힌트: 모든 공개 API 함수에 필수.
Optional[X]대신X | None을 사용하세요. - 도큐스트링: 모든 공개 클래스와 함수에 대해 Google 스타일을 사용하세요.
- 이름 지정: Python 관례를 따르세요 — 함수와 변수는
snake_case, 클래스는PascalCase를 사용하세요. - 줄 길이: 119자 (
pyproject.toml에서 설정). - 무조건
except금지: 항상 구체적인 예외 유형을 캐치하세요.
---
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 설치
스킬 파일을 다운로드하여 .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
복사





집
