enthought / enthought/comtypes
Refactor from `%` string formatting to f-strings in every module.
- Dominant language
- Python
- Stars
- 345
- Forks
- 105
- PR merge metrics
- No merged PRs in 30d
Description
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](https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals).
- Most of the changes should follow these patterns:
- Replace `"...%s..." % foo` with `f"...{foo}..."`
- Replace `"...%r..." % foo` with `f"...{foo!r}..."`
- Replace `"...%x..." % foo` with `f"...{foo:x}..."`
- Replace `"...%d..." % foo` with `f"...{foo:d}..."`
- Replace `"...\\%s..." % foo` with `f"...\\{foo}..."`
- Replace `r"...\%s..." % foo` with `rf"...\{foo}..."`
- There’s NO need to modify placeholders in logger method calls, as shown below.
https://github.com/enthought/comtypes/blob/083c19e9fdc0f366df48ad448e897246f346ede0/comtypes/__init__.py#L137-L141
- 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/...`
- [x] `comtypes/_comobject.py`
- [x] `comtypes/_memberspec.py`
- [x] `comtypes/_post_coinit/_cominterface_meta_patcher.py`
- [x] `comtypes/automation.py`
- [x] `comtypes/client/_code_cache.py`
- [x] `comtypes/client/_constants.py`
- [x] `comtypes/client/_events.py`
- [x] `comtypes/client/_generate.py`
- [x] `comtypes/client/lazybind.py`
- [x] `comtypes/errorinfo.py`
- [x] `comtypes/server/inprocserver.py`
- [x] `comtypes/server/register.py`
- [x] `comtypes/server/w_getopt.py`
- [x] `comtypes/tools/codegenerator/codegenerator.py`
- [x] `comtypes/tools/codegenerator/helpers.py`
- [x] `comtypes/tools/codegenerator/packing.py`
- [x] `comtypes/tools/tlbparser.py`
- [x] `comtypes/tools/typedesc.py`
- [x] `comtypes/typeinfo.py`
- [x] `comtypes/viewobject.py`
## Under the `comtypes/test/...`
- [x] `comtypes/test/__init__.py`
- [x] `comtypes/test/test_BSTR.py`
- [x] `comtypes/test/test_avmc.py`
- [x] `comtypes/test/test_casesensitivity.py`
- [x] `comtypes/test/test_collections.py`
- [x] `comtypes/test/test_comserver.py`
- [x] `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`
Contributor guide
Assessment
This issue has not been assessed yet.