Skip to content

Modernize string formatting to f-strings#201

Merged
derek73 merged 1 commit into
masterfrom
task/update-string-formats
Jul 4, 2026
Merged

Modernize string formatting to f-strings#201
derek73 merged 1 commit into
masterfrom
task/update-string-formats

Conversation

@derek73

@derek73 derek73 commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

Modernized all string formatting across the codebase from Python 2-era styles (% formatting, .format()) to Python 3.10+ f-strings.

Changes

  • Converted all .format() and % formatting to f-strings across main code, tests, and docs
  • Updated ruff config to remove UP031/UP032 ignores (legacy Python 2 compatibility)
  • Added noqa comments to dynamic template .format() calls that can't be converted (e.g., string_format.format(**dict))
  • Improved test readability by using SimpleNamespace for dot notation access in test_variations.py
  • Refactored __repr__ method in parser.py for better readability—broke long f-string into multi-line attrs construction

Files Changed

  • nameparser/parser.py: Converted .format() and % formatting to f-strings, refactored repr
  • nameparser/config/__init__.py: Converted .format() to f-string in SetManager.repr
  • tests/test_variations.py: Converted to f-strings with SimpleNamespace for dot notation
  • tests/base.py: Converted % formatting to f-strings in assertion messages
  • docs/conf.py: Converted .format() with format spec to f-string
  • pyproject.toml: Removed UP031 and UP032 from ruff ignore list

Testing

✅ All 1182 tests pass
✅ All ruff checks pass (including the now-enabled UP031/UP032 rules)

- Convert all .format() and % formatting to f-strings across codebase
- Update ruff config to remove UP031/UP032 ignores (Python 2 legacy)
- Add noqa comments to dynamic template .format() calls (can't convert to f-strings)
- Use SimpleNamespace for dot notation access in test_variations.py
- Refactor __repr__ method for improved readability
- All 1182 tests pass, ruff checks pass

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@derek73 derek73 self-assigned this Jul 4, 2026
@derek73 derek73 added this to the v1.3.0 milestone Jul 4, 2026
@derek73 derek73 merged commit e3d8b14 into master Jul 4, 2026
8 checks passed
@derek73 derek73 deleted the task/update-string-formats branch July 4, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant