Skip to content

Python: Honor literal Markdown paths in --no-glob mode - #9691

Closed
LI (ktz03) wants to merge 1 commit into
microsoft:mainfrom
ktz03:fix/markdown-literal-paths-20261026
Closed

LI (ktz03) wants to merge 1 commit into
microsoft:mainfrom
ktz03:fix/markdown-literal-paths-20261026

Conversation

@ktz03

Copy link
Copy Markdown
Contributor

Motivation & Context

The Markdown checker promises literal file paths with --no-glob, and the changed-file hook uses that option. It still passes those paths directly to glob.glob. A valid file named guide[1].md is silently skipped, or guide1.md is checked instead when both exist. Brackets in a parent directory have the same effect.

Description & Review Guide

  • What are the major changes? Escape glob metacharacters only in the existing literal-path branch. Add eight focused regressions and run them in the existing Samples & Markdown job with the declared tool-markdown dependency group.
  • What is the impact of these changes? The requested Markdown file is selected exactly. Normal glob expansion, recursive patterns, missing/non-Markdown filtering, sorting and deduplication retain their existing behavior. No snippet parsing or type-checking behavior changes.
  • What do you want reviewers to focus on? The eight regressions import the complete script and include its real CLI. On Windows with Python 3.14.3 and Pygments 2.21.0, the unchanged source fails four cases and passes four controls; the fix passes all eight. Fixture snippets contain no framework imports, so uv/Pyright, framework SDKs, builds and the full workspace suite were not run. The new CI step has not been run on GitHub; existing job failure policies are unchanged.

Related Issue

N/A - trivial change. This restores the existing option's explicit "literal paths (no glob expansion)" contract without changing the ordinary glob mode or introducing new behavior to configure.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Codex: implementation, regression tests, and this PR description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change.

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.

🟢 Approval recommended

The fix is narrowly scoped, the regression tests cover the reported failure and preserved behavior, and no blocking issues were identified.

No open issues 🎉

What changed in this PR

This PR restores the Markdown checker’s literal-path behavior for --no-glob, including paths containing brackets, without changing normal glob expansion.

Changes:

  • Escape glob metacharacters in the literal-path branch.
  • Add eight regression tests covering literal selection, existing filtering and glob behavior, and the real CLI.
  • Run the tests in the existing Samples & Markdown CI job using the tool-markdown dependency group.
File Description
python/​scripts/​tests/​test_check_md_code_blocks.py Adds eight file-selection and CLI regression tests.
python/​scripts/​check_md_code_blocks.py Escapes literal paths before passing them to glob.glob.
.github/​workflows/​python-code-quality.yml Adds the regression tests to the existing CI job.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
github-app-auth — 494462e4 Deployed Oct 26, 2026 by ktz03 via team_check #7445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants