Skip to content

[flake8-todos] Recognize Jira-style issue IDs on the TODO line (TD003)#25066

Closed
kimjune01 wants to merge 1 commit into
astral-sh:mainfrom
kimjune01:fix-16519-td003-hyphens
Closed

[flake8-todos] Recognize Jira-style issue IDs on the TODO line (TD003)#25066
kimjune01 wants to merge 1 commit into
astral-sh:mainfrom
kimjune01:fix-16519-td003-hyphens

Conversation

@kimjune01

Copy link
Copy Markdown

Summary

Fixes #16519. TD003 currently only recognizes URLs and #NNN codes on the
same line as a TODO comment. Jira-style issue IDs like PROJ-123 are only
matched on a separate line, causing false positives for projects that write
# TODO: PROJ-123 fix the widget.

This adds four regex patterns to ISSUE_LINK_TODO_LINE_REGEX_SET that
recognize Jira-style IDs ([A-Z]{2,}-\d+) in the positions MichaReiser
requested in #20880:

  • Directly after the colon: TODO: PROJ-123 ...
  • At end of line: TODO: fix this PROJ-123
  • In parentheses: TODO: fix bug (PROJ-123)
  • Followed by a colon: TODO: PROJ-123: fix bug

The {2,} minimum on the uppercase prefix aligns with Jira's project key
requirements and prevents single-letter matches like A-1.

Prior work: #20880 by @danparizher addressed the same issue but stalled
after review feedback requesting tighter patterns. This PR incorporates
that feedback directly.

Test Plan

  • Added 7 test cases to TD003.py fixture covering valid Jira-style
    patterns (after colon, parentheses, end of line, followed by colon)
    and invalid patterns (single-letter key, no hyphen, lowercase)
  • Updated snapshot to reflect corrected diagnostics
  • Verified on main: new fixture causes snapshot mismatch (7 extra violations)
  • Verified on fix branch: all flake8_todos tests pass

This PR was developed with AI assistance (Claude). All pattern choices
trace to MichaReiser's review feedback on #20880.

Add regex patterns for PROJ-123 style IDs after colon, at end
of line, in parentheses, and followed by colon. Two-char minimum
on the uppercase prefix matches Jira project key requirements.

Fixes astral-sh#16519
@astral-sh-bot astral-sh-bot Bot requested a review from ntBre May 9, 2026 09:49
@MichaReiser

Copy link
Copy Markdown
Member

Thank you. I'll close this PR, because it's mainly produced by AI and the summary doesn't explain why certain decisions were made (except that they are based on my review feedback, but why is this the desired behavior?).

@kimjune01

kimjune01 commented May 11, 2026

Copy link
Copy Markdown
Author

Sorry for the noise. If you'd like to automatically block and ban AI PRs before they reach your review queue, here's a GitHub Action that catches all the common patterns: https://github.com/kimjune01/sweep/blob/master/action.yml

@kimjune01

Copy link
Copy Markdown
Author

@MichaReiser ^

@kimjune01

Copy link
Copy Markdown
Author

Sorry for the noise. If you'd like to auto-close PRs like this before they reach your review queue, I built a GitHub Action that catches the common patterns: https://github.com/kimjune01/sweep#pr-quality-gate

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TD003 error in regex or misleading error message

3 participants