Skip to content

refactor: call match.group once per field in __format__#11

Merged
underwoo merged 1 commit into
mainfrom
fix/issue-6-match-group-once
Jun 22, 2026
Merged

refactor: call match.group once per field in __format__#11
underwoo merged 1 commit into
mainfrom
fix/issue-6-match-group-once

Conversation

@underwoo

Copy link
Copy Markdown
Owner

Fixes #6

Each named regex group was fetched twice — once for truthiness, once for the value. Fixed with or operator:

# Before
fill = match.group("fill") if match.group("fill") else fill

# After
fill = match.group("fill") or fill

(width still uses the conditional form since int(None) raises.)

Verification:

  • pytest: 47/47 passed
  • mypy: clean
  • pylint: clean

Closes #6

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@underwoo underwoo merged commit 3b425db into main Jun 22, 2026
9 checks passed
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.

refactor: match.group() called twice per field in __format__

1 participant