Last active
February 12, 2026 18:04
-
-
Save rgant/60ba3dcaabdf85cae9d3dcdbbe4ae016 to your computer and use it in GitHub Desktop.
Shell script duplicate of pylint-ruff-sync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| gh issue view 970 --repo astral-sh/ruff --json body --jq '.body' \ | |
| | awk ' | |
| function trim(s) { gsub(/^[[:space:]]+|[[:space:]]+$/, "", s); return s } | |
| BEGIN { | |
| started = 0 | |
| # Rules to comment out in the output | |
| comment_out["bad-dunder-name"] = 1 | |
| comment_out["compare-to-empty-string"] = 1 | |
| comment_out["consider-using-any-or-all"] = 1 | |
| comment_out["consider-using-augmented-assign"] = 1 | |
| comment_out["consider-using-ternary"] = 1 | |
| comment_out["docstring-first-line-empty"] = 1 | |
| comment_out["empty-docstring"] = 1 | |
| comment_out["import-private-name"] = 1 | |
| comment_out["invalid-bool-returned"] = 1 | |
| comment_out["missing-class-docstring"] = 1 | |
| comment_out["missing-function-docstring"] = 1 | |
| comment_out["missing-module-docstring"] = 1 | |
| comment_out["modified-iterating-set"] = 1 | |
| comment_out["no-classmethod-decorator"] = 1 | |
| comment_out["no-self-use"] = 1 | |
| comment_out["no-staticmethod-decorator"] = 1 | |
| comment_out["too-many-boolean-expressions"] = 1 | |
| comment_out["too-many-locals"] = 1 | |
| comment_out["too-many-positional-arguments"] = 1 | |
| comment_out["too-many-public-methods"] = 1 | |
| comment_out["trailing-newlines"] = 1 | |
| comment_out["try-except-raise"] = 1 | |
| comment_out["unnecessary-dunder-call"] = 1 | |
| comment_out["unnecessary-lambda"] = 1 | |
| comment_out["unspecified-encoding"] = 1 | |
| comment_out["use-maxsplit-arg"] = 1 | |
| } | |
| # Print headings as-is; also use the first heading to start output | |
| /^#/ { started = 1; print; next } | |
| # Ignore anything before the first markdown heading | |
| !started { next } | |
| # Skip unchecked items | |
| /^- \[ \]/ { next } | |
| # Transform checked items | |
| /^- \[[xX]\]/ { | |
| line = $0 | |
| # Remove tildes (covers ~`...`...~) | |
| gsub(/~/, "", line) | |
| # Extract the first backtick-quoted string and quote it | |
| if (match(line, /`[^`]+`/)) { | |
| name = substr(line, RSTART + 1, RLENGTH - 2) | |
| } else { | |
| next | |
| } | |
| out = "\"" name "\"," # always ends with a comma | |
| # If parentheses exist, normalize and append comment | |
| if (match(line, /\([^)]*\)/)) { | |
| par = substr(line, RSTART + 1, RLENGTH - 2) | |
| # Remove backticks | |
| gsub(/`/, "", par) | |
| # Trim whitespace; normalize comma spacing; trim stray edge commas | |
| par = trim(par) | |
| gsub(/[[:space:]]*,[[:space:]]*/, ", ", par) | |
| par = trim(par) | |
| gsub(/^[,]+|[,]+$/, "", par) | |
| par = trim(par) | |
| # Append comment | |
| out = out " # Duplicated with Ruff (" par ")" | |
| } | |
| if (name in comment_out) out = "# " out | |
| print out | |
| next | |
| } | |
| # Everything else: drop | |
| { next } | |
| ' |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is my version of https://github.com/cidrblock/pylint-ruff-sync