-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)
Description
Feature or enhancement
Proposal:
Description
Lib/uuid.py currently uses older string formatting methods (% operator and .format()) in a few places. This task resolves to modernizing these to use f-strings (PEP 498) for improved readability and consistency with modern Python codebases.
Proposed Changes
- Replace
'%s(%r)' % (self.__class__.__name__, str(self))withf'{self.__class__.__name__}({str(self)!r})'inUUID.__repr__. - Replace
os.fsencode('(%s)' % ip_addr)withos.fsencode(f'({ip_addr})')in_arp_getnode. - Replace
assert False, '_random_getnode() returned invalid value: {}'.format(_node)withf-stringversion ingetnode.
Verification
- Run
python Lib/test/test_uuid.pyto ensure all tests pass.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)