[New-bugs-announce] [issue44712] Replace `type(literal)` with corresponding builtin types
Serhiy Storchaka
report at bugs.python.org
Thu Jul 22 16:41:11 EDT 2021
New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:
There are several occurrences of type(literal) in the code of the stdlib where literal is a literal of built-in type: '', 1, [], {}, etc. I suppose it is a remnants of very old code written when str, int, list, dict, etc were functions and not classes.
The proposed PR replaces `type(literal)` with corresponding builtin types. It makes the code cleaner.
I consider also idea of replacing identity or equality checks ("is" or "==") with isinstance(). I suppose that that code was written when built-in types were not subclassable. But now there is a reason to use isinstance().
See also issue44711.
----------
components: Library (Lib)
messages: 398002
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Replace `type(literal)` with corresponding builtin types
versions: Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44712>
_______________________________________
More information about the New-bugs-announce
mailing list