GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — `ParamSpec` substitution: difference in behaviour between `collections.abc.Callable` and `typing.Callable` · Issue #102723 · python/cpython Closed as not planned Closed as not planned Copy link Labels 3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionThere is currently a difference in behaviour between Running PGUpdate|x64 interpreter... Python 3.12.0a6+ (heads/main:12226bec25, Mar 10 2023, 17:32:23) [MSC v.1932 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import typing as t, collections.abc as c >>> P, T = t.ParamSpec("P"), t.TypeVar("T") >>> t.Callable[P, T][[P, str], bool][int] typing.Callable[[int, str], bool] >>> c.Callable[P, T][[P, str], bool][int] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<frozen _collections_abc>", line 501, in __getitem__ File "<frozen _collections_abc>", line 456, in __new__ TypeError: Callable must be used as Callable[[arg, ...], result]. According to PEP-612, this is an invalid substitution, for two reasons:
As such, the behaviour of However, this error should hopefully be caught by static type checkers anyway, and this is a false negative rather than a false positive. The runtime makes no promises that it will raise This discrepancy in behaviour was first uncovered as part of a broader discussion in: Cc. @sobolevn Activity
MetadataMetadataAssigneesLabels3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |