You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 59a9e85
Browse filesBrowse the repository at this point in the historyBrowse files
[ty] Generalize nested types in inferred return types (astral-sh#29488)
## Summary
Generalize/promote types in inferred return types that refer to local
nested definitions.
For example, consider this unannotated decorator:
```python
def register(event: str):
def wrapper(func):
# ...
return func
return wrapper
```
We do not want to infer `def wrapper(func) -> Unknown` as the return
type of `register`. This would not just expose internal details, it
would also incorrectly suggest that each call to `register` returns the
same function object. Instead, we generalize to an anonymous `(func) ->
Unknown` callable.
For nested classes, we cannot easily do the same, so we return `Unknown`
instead. In the future, to improve this, we might want to synthesize a
protocol that has the same attributes and methods as the nested class.
## Test strategy
Updated existing mdtests
0 commit comments