Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
> issubclass(x, list[int]) rejects the second argument for reasons explained in > the PEP. 1. One problem is that isinstance(x, type) != issubclass(type(x), type) if x is list[int]. It is unprecedented, I cannot recall any other case in which isinstance() and issubclas() are inconsistent. Ant it breaks code because these two expressions are often considered equivalent and interchangeable in refactoring. 2. Other problem is that isinstance(x, type) is used as a guard before using x as a type. `isinstance(obj, type) and issubclass(obj, SomeClass)` is a common idiom, because issubclass() raises an exception if its first argument is not a type. It is now broken for list[int]. > What other places are there that are broken because of this? $ find Lib -name '*.py' \! -path '*/test*' -exec egrep 'isinstance.*, type\)' '{}' + | wc -l 55 In msg403826 I showed few examples from just two files, but there are tens more potential examples. I'll show them all if I have enough of spare time. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45438> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com