pyansys-quality-report setup#

The pyansys-quality-report command runs repository quality checks.

Setup#

Add the hook to .pre-commit-config.yaml:

- repo: https://github.com/ansys/pre-commit-hooks
  rev: v0.8.4
  hooks:
  - id: pyansys-quality-report
    args: [--show-all]
    verbose: true

Run the hook on the whole repository with pre-commit or prek:

pre-commit run pyansys-quality-report --all-files
prek run pyansys-quality-report --all-files

The verbose: true option makes pre-commit print the report even when the hook passes. Without it, output from a passing hook, including --show-all results, is hidden.

The project root is the nearest directory, starting from the current one and moving up, that contains a pyproject.toml. If none does, the current directory is used.

Rules#

Checks are grouped into rule families, and each rule has a unique ID. Use --metadata to list the available rules and their descriptions. Select individual rules with --check, exclude them with --ignore, or select a family with --family. All registered families run by default. Use --help to see the available command options.

CLI options#

Passing checks are hidden by default. Use --show-all to include them. Select or ignore checks with comma-separated or repeated IDs:

pyansys-quality-report --show-all
pyansys-quality-report --check RM003
pyansys-quality-report --ignore RM004,RM005
pyansys-quality-report --format text
pyansys-quality-report --color always
pyansys-quality-report --format json
pyansys-quality-report --format json --output-file quality-report.json
pyansys-quality-report --metadata

The report format defaults to text; use --format json for JSON output. Reports are printed to standard output unless --output-file is used with --format json to write a JSON report to a file.

Ignore rules persistently by listing their IDs in pyproject.toml:

[tool.pyansys-quality-report]
ignore = ["PM023", "PM027"]

Rule IDs in this setting are combined with IDs passed through --ignore.

Every rule reports one of four statuses: PASSED, RECOMMENDATION, WARNING, or ERROR. The text report colors these statuses green, cyan, yellow, and red by default, including captured pre-commit and CI output. Use --color never for plain text or --color auto to enable colors only for interactive terminals. In automatic mode, NO_COLOR disables color and a nonzero FORCE_COLOR value enables it. Recommendations, warnings, and errors display their actual message once. Recommendations are optional improvements and, like warnings, do not produce a non-zero exit code; errors do. The score uses passed and error results only. The tech-review hook remains unchanged.