PyMuPDF icon indicating copy to clipboard operation
PyMuPDF copied to clipboard

Cleanup string formatting.

Open knotapun opened this issue 7 months ago • 9 comments

This commit attempts to clean out old cruft, to make room for new cruft. This is clearly not the most pressing issue in the world, however I think it's far more legible.

This change consists of:

  • Replacing most %-strings with f-strings.
  • Cleanup a few areas where repeated string formatting logic was used, by using a loop instead.

knotapun avatar Jul 02 '25 20:07 knotapun

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

github-actions[bot] avatar Jul 02 '25 20:07 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

knotapun avatar Jul 02 '25 20:07 knotapun

recheck

knotapun avatar Jul 02 '25 20:07 knotapun

Read through the action result, and it looks like it wasn't happy about an extra line, and I forgot to wrap arguments for the SQLite call in the sample, so it did a different form of injection. Ironic. At least it failed fast?

knotapun avatar Jul 03 '25 03:07 knotapun

  • The raise syntax is invalid here. It should be raise ValueError(f"max. code point found: {ord(max(text))}, increase limit") without the colon after ValueError.
               raise ValueError:(f"max. code point found: {ord(max(text))}, increase limit")

src/utils.py:1640

The syntax error is real, but I didn't introduce it. That's easy to fix though.

knotapun avatar Jul 16 '25 17:07 knotapun

Everything copilot complained about, (Except the pass thing, which it was wrong about), I fixed. I don't think the dictionary thing makes a difference speed wise, but I think it's stylistically better.

knotapun avatar Jul 16 '25 17:07 knotapun

@knotapun Would it be possible to squash your commits here?

jamie-lemon avatar Jul 17 '25 11:07 jamie-lemon

They're now squashed into one commit. Git is my biggest weakness, sorry if this is not the appropriate way to do this.

knotapun avatar Jul 17 '25 18:07 knotapun

Looks good to me, my "git-fu" is also pretty weak when it comes to this sort of thing!

As far as a I am concerned this PR is fine, but I think we need to spend some time double checking and testing that none of our tests are broken (which I doubt). So don't be surprised if it takes a few days :)

jamie-lemon avatar Jul 17 '25 21:07 jamie-lemon