Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
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 1SyntaxError: yield expression cannot be used within a TypeVar bound
>>> def f[T: (int, (yield))](): pass File "<python-input-2>", line 1SyntaxError: yield expression cannot be used within a TypeVar boundWe 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