-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor from %
string formatting to f-strings in every module.
#657
Comments
I looked for the use location by git grep -n '%[sdxXorfFeEgGc]' I will split modification into several PRs by file or dir. result
|
Thank you for your investigation. Please note that the grep results mentioned above include items like Happy contributing! |
@junkmd Thank you for your support. I investigated by Result
|
Hi @newwingbird, Thanks for your quick response. I noticed that |
Okay, In addition, |
I might have missed it, but if
That's right. |
We became confused about the combination of
As shown below, these patterns are equivalent regardless of the chosen style. >>> foo = 123
>>> "...\\%s..." % foo
'...\\123...'
>>> f"...\\{foo}..."
'...\\123...'
>>> r"...\%s..." % foo
'...\\123...'
>>> rf"...\{foo}..."
'...\\123...'
>>> However, to keep changes minimal, let’s ensure the number of backslashes remains the same before and after changes within the scope of this issue. We can decide whether to standardize them after this issue is closed. |
The Can you accept to limit the scope of this issue to the |
I think so. We should replan the scope of issues. |
Thank you for agreeing. I have removed "Others" from the kanban and limited the to-do list to only the Please keep up the great work as a contributor! |
We could replace
%
string formatting with f-strings wherever applicable, as was done in #654.For details on f-string syntax, refer to the Python official documentation.
Most of the changes should follow these patterns:
"...%s..." % foo
withf"...{foo}..."
"...%r..." % foo
withf"...{foo!r}..."
"...%x..." % foo
withf"...{foo:x}..."
"...%d..." % foo
withf"...{foo:d}..."
"...\\%s..." % foo
withf"...\\{foo}..."
r"...\%s..." % foo
withrf"...\{foo}..."
There’s NO need to modify placeholders in logger method calls, as shown below.
comtypes/comtypes/__init__.py
Lines 137 to 141 in 083c19e
We welcome keeping changes as small as possible per pull request, as it makes it easier for reviewers to check the changes.
If your PR addresses multiple rules or files, reviewers might consider it a large change and suggest splitting it into multiple PRs.
TODO list
Under the
comtypes/...
comtypes/_comobject.py
comtypes/_memberspec.py
comtypes/_post_coinit/_cominterface_meta_patcher.py
comtypes/automation.py
comtypes/client/_code_cache.py
comtypes/client/_constants.py
comtypes/client/_events.py
comtypes/client/_generate.py
comtypes/client/lazybind.py
comtypes/errorinfo.py
comtypes/server/inprocserver.py
comtypes/server/register.py
comtypes/server/w_getopt.py
comtypes/tools/codegenerator/codegenerator.py
comtypes/tools/codegenerator/helpers.py
comtypes/tools/codegenerator/packing.py
comtypes/tools/tlbparser.py
comtypes/tools/typedesc.py
comtypes/typeinfo.py
comtypes/viewobject.py
Under the
comtypes/test/...
comtypes/test/__init__.py
comtypes/test/test_BSTR.py
comtypes/test/test_avmc.py
comtypes/test/test_casesensitivity.py
comtypes/test/test_collections.py
comtypes/test/test_comserver.py
comtypes/test/test_createwrappers.py
comtypes/test/test_dispinterface.py
comtypes/test/test_excel.py
comtypes/test/test_outparam.py
comtypes/test/test_safearray.py
comtypes/test/test_sapi.py
comtypes/test/test_server.py
comtypes/test/test_urlhistory.py
comtypes/test/test_variant.py
comtypes/test/test_word.py
The text was updated successfully, but these errors were encountered: