Implementation:Scikit learn Scikit learn GetComment
| Knowledge Sources | |
|---|---|
| Domains | Build Tools, CI/CD |
| Last Updated | 2026-02-08 15:00 GMT |
Overview
Concrete tool for generating GitHub PR comments when linting issues are detected provided by scikit-learn.
Description
This script is used by the "Comment on failed linting" GitHub Action to generate structured comments on pull requests when linting issues are detected. It parses linting job logs, extracts failure information for specific lint steps, and posts or updates comments on the PR using the GitHub API. The script reads package version information and formats the comment with detailed error messages and suggested fixes.
Usage
Use this script as part of the CI/CD pipeline to automatically post informative comments on pull requests that fail linting checks, helping contributors understand and fix code quality issues.
Code Reference
Source Location
- Repository: scikit-learn
- File: build_tools/get_comment.py
Signature
def get_versions(versions_file)
def get_step_message(log, start, end, title, message, details)
Import
from github import Auth, Github, GithubException
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| versions_file | str | Yes | Path to file containing linter package versions |
| log | str | Yes | Full log output of the linting job |
| start | str | Yes | Marker string indicating start of a test section |
| end | str | Yes | Marker string indicating end of a test section |
| title | str | Yes | Title for the comment section |
| message | str | Yes | Message to display at beginning of the section |
| details | bool | Yes | Whether to include detailed step output |
Outputs
| Name | Type | Description |
|---|---|---|
| versions | dict | Dictionary of linter package versions |
| message | str | Formatted comment message for the PR |
| GitHub comment | PR comment | Posted or updated comment on the pull request |
Usage Examples
Basic Usage
# Typically invoked by GitHub Actions, not directly
# Example of reading versions:
from build_tools.get_comment import get_versions
versions = get_versions("versions.txt")
print(versions)
# {'ruff': '0.1.0', 'cython-lint': '0.15.0', ...}