Skip to content

fix(artifacts): read Python module descriptions after header comments - #5099

Open
Ghoscro wants to merge 4 commits into
github:mainfrom
Ghoscro:fix/python-artifact-docstrings
Open

Ghoscro wants to merge 4 commits into
github:mainfrom
Ghoscro:fix/python-artifact-docstrings

Conversation

@Ghoscro

@Ghoscro Ghoscro commented Oct 23, 2026 •

Copy link
Copy Markdown

Description

A Python script with an encoding or copyright header before its module docstring can show that header as its description in artifact list and artifact info.

Read only the leading string expression, without executing the script or parsing its remaining code. This also works when the script body uses syntax newer than the CLI's Python interpreter. Decode ordinary/raw/adjacent/parenthesized string literals without emitting compiler warnings or changing global warning filters. Preserve docstring whitespace cleaning and the existing comment fallback for missing or malformed descriptions; non-Python handling remains unchanged.

Validation

  • Public CLI regressions cover headers, malformed input, newer trailing syntax, string semantics and warning-free decoding. Complete artifact suites: 437 passed on Python 3.11.15 and 437 passed on Python 3.13.12.
  • A deterministic overlap test reproduces the prior global warning-filter leak and passes after the fix. Independent comparison also confirms unrelated thread warnings remain visible. Literal values and leading-expression behavior were checked against Python's native parsers.
  • Full Python 3.13 suite: 13,153 passed, 128 skipped, 62 existing warnings (269.31s), against the final source and tests.
  • Ruff lint, changed-test formatting and whitespace checks pass. Existing unrelated formatting remains untouched. Isolated fixtures fail if executed; validation performs no live community writes.

Hosted results for the newest commit are recorded separately from local results.

AI Disclosure

OpenAI Codex (GPT-6, autonomous; reasoning effort not exposed) prepared the investigation, code, tests and follow-ups on behalf of @Ghoscro. A separate Codex agent reviewed the final diff and independently checked the concurrency and literal semantics. No human line-by-line review is claimed. Supplemental commits carry Assisted-by disclosure.

Assisted-by: OpenAI Codex (model: GPT-6, autonomous)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Confirmed gaps in parser error handling can make artifact commands fail on project scripts.

2 open issues
What changed in this PR

Fixes Python script descriptions in Spec Kit’s artifact catalog so module docstrings take precedence over encoding and license comments, without executing scripts.

Changes:

  • Adds AST-based extraction for Python files while preserving existing fallbacks and non-Python handling.
  • Adds four regression cases covering header comments and blank or missing docstrings through both list and info paths.

Validation used isolated standard-library probes; the reported project test suites were not rerun.

File Description
tests/​specify_cli/​artifacts/​test_catalog.py Adds public-path regression coverage for Python script descriptions.
src/​specify_cli/​artifacts/​catalog.py Reads Python module docstrings before applying existing fallbacks.

Review effort: Max

Comment thread src/specify_cli/artifacts/catalog.py Outdated
Comment thread src/specify_cli/artifacts/catalog.py Outdated
@mnriem

mnriem commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

@mnriem mnriem added the triage-nice-to-have Verdict: evidence-backed fix or greenlit feature — land after review label Oct 23, 2026
Handle parser resource errors with the existing comment fallback and suppress metadata-only parser warnings locally.

Assisted-by: OpenAI Codex (model: GPT-6, autonomous)
@Ghoscro

Ghoscro commented Oct 23, 2026

Copy link
Copy Markdown
Author

Addressed both Copilot findings in db3b52a: parser recursion/memory errors now use the existing comment fallback, and metadata parsing suppresses warnings locally while restoring the caller's warning filters.

Nine new regressions exercise real script source through artifact list, the affected script's info, and an unrelated artifact's info: all nine failed before and pass after. A separate Codex agent independently reran them and reviewed the change. The artifact suite passes 362 tests; the full suite passes 13,078 with 128 skips and 62 warnings. Six installed CLI checks returned expected descriptions and empty stderr. Ruff lint, new-test formatting and whitespace checks pass. The final uploaded tree exactly matches the tested local tree. Hosted CI for this new commit is pending.

@mnriem, this is ready for another look when convenient.

AI disclosure: OpenAI Codex (model: GPT-6, autonomous) prepared, tested and posted this follow-up on behalf of @Ghoscro. No human line-by-line review is claimed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An uncaught parser exception on supported Python 3.11 can abort artifact list and info commands.

2 open issues
2 resolved since last review

Review effort: Max

Comment thread src/specify_cli/artifacts/catalog.py Outdated
Comment thread tests/specify_cli/artifacts/test_description_parsing.py Outdated
Assisted-by: OpenAI Codex (model: GPT-6, autonomous)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Concurrent metadata parsing can leave process-wide warnings suppressed in the long-lived MCP server.

2 open issues
2 resolved since last review

Review effort: Max

Comment thread src/specify_cli/artifacts/catalog.py Outdated
Comment on lines +162 to +163
with warnings.catch_warnings():
warnings.simplefilter("ignore")
Comment thread src/specify_cli/artifacts/catalog.py Outdated
Comment on lines +164 to +166
description = ast.get_docstring(ast.parse(text))
except (SyntaxError, ValueError, RecursionError, MemoryError):
description = None
Assisted-by: OpenAI Codex (model: GPT-6, autonomous)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage-nice-to-have Verdict: evidence-backed fix or greenlit feature — land after review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants