Skip to content

Conversation

@newwingbird
Copy link
Contributor

@newwingbird newwingbird commented Nov 17, 2024

Related to #657

Out of scope

  • comtypes/client/init.py
  • comtypes/server/connectionpoints.py
  • comtypes/client/init.py
  • comtypes/server/connectionpoints.py

Note

I investigated by git grep -n '%[sdxXorfFeEgGc]' | grep -v 'logger\.debug' | grep -v '_debug' | grep -v '_warning' | grep -v 'logger\.info' | grep -v '_error'

The following code would be listed with this command.
So Issue's todo list will be changed.

            _error(
                "Exception in %s.%s implementation:",
                interface.__name__,
                mthname,
                exc_info=True,
            )

@newwingbird newwingbird changed the title Update by fstring Updating by fstring Nov 17, 2024
@junkmd junkmd added the coding style Topics related to style, formatters, linters, and delinting. label Nov 17, 2024
@junkmd junkmd added this to the 1.4.9 milestone Nov 17, 2024
@junkmd
Copy link
Collaborator

junkmd commented Nov 17, 2024

Out of scope

  • comtypes/client/init.py
  • comtypes/server/connectionpoints.py
  • comtypes/client/init.py
  • comtypes/server/connectionpoints.py

The following code would be listed with this command. So Issue's todo list will be changed.

            _error(
                "Exception in %s.%s implementation:",
                interface.__name__,
                mthname,
                exc_info=True,
            )

Good catch!
I will remove them from the issue kanban.

Copy link
Collaborator

@junkmd junkmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

append(… could likely be replaced with f-strings for other lines as well.

@junkmd
Copy link
Collaborator

junkmd commented Nov 17, 2024

To avoid further confusion while working on this issue, I’ve added examples to the issue kanban.

  • Replace "...\\%s..." % foo with f"...\\{foo}..."
  • Replace r"...\%s..." % foo with rf"...\{foo}..."

#657 (comment)

junkmd added a commit to junkmd/pywinauto that referenced this pull request Nov 20, 2024
if hasattr(head.struct, "_recordinfo_"):
print(
" _recordinfo_ = %r" % (head.struct._recordinfo_,),
f" _recordinfo_ = {head.struct._recordinfo_!r}",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit complicated, but it's equivalent, so there's no problem.

>>> info = ('{07D2AEE5-1DF8-4D2C-953A-554ADFD25F99}', 1, 0, 0, '{00FABB0F-5691-41A6-B7C1-11606671F8E5}')
>>> f" _recordinfo_ = {info!r}"
" _recordinfo_ = ('{07D2AEE5-1DF8-4D2C-953A-554ADFD25F99}', 1, 0, 0, '{00FABB0F-5691-41A6-B7C1-11606671F8E5}')"
>>> " _recordinfo_ = %r" % (info,)
" _recordinfo_ = ('{07D2AEE5-1DF8-4D2C-953A-554ADFD25F99}', 1, 0, 0, '{00FABB0F-5691-41A6-B7C1-11606671F8E5}')"

junkmd added a commit to junkmd/pywinauto that referenced this pull request Nov 20, 2024
junkmd added a commit to junkmd/pywinauto that referenced this pull request Nov 20, 2024
Copy link
Collaborator

@junkmd junkmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your efforts.

I’ve reviewed several PRs related to #657 and have come to the conclusion that the optimal amount of changes for this type of replacement is about 30 lines per PR.

Of course, there may be cases related to #657 where changes exceeding 30 lines are necessary for a single file. In such cases, please create a PR for that file only.

@junkmd junkmd merged commit fb15f91 into enthought:main Nov 21, 2024
49 checks passed
@junkmd junkmd linked an issue Nov 21, 2024 that may be closed by this pull request
36 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coding style Topics related to style, formatters, linters, and delinting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor from % string formatting to f-strings in every module.

2 participants