-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
We disallow certain expressions (e.g., yield
) in type parameters bounds, constraints, and defaults. But the error message always says it's a bound:
>>> def f[T=(yield)](): pass
File "<python-input-0>", line 1
SyntaxError: yield expression cannot be used within a TypeVar bound
>>> def f[T: (int, (yield))](): pass
File "<python-input-2>", line 1
SyntaxError: yield expression cannot be used within a TypeVar bound
We could either add some machinery in the symbol table so it knows whether we're in a bound, constraints, or default, or just change the error message to something like "within a TypeVar bound, constraints, or default".
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
AlexWaygood and Eclips4
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error