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
Allow redefinitions for function arguments (python#20853)
Fixespython#19918
Implementation is straightforward, but logic behind is essentially a
compromise. Both empty context and full type context for redefinition
have pros and cons. We select full context first for function arguments
because:
* It avoids false positives in at least some of the "covariant
normalization" patterns. For example `list[str | None]` to `list[str]`
_in a branch_ will infer `list[str | None]` instead of `list[str | None]
| list[str]`. Unconditional normalization like `list[str | None]` to
`list[str]` still doesn't work, but it doesn't work for empty context
either.
* Conceptually function arguments are in between annotated and annotated
variables, in the sense that user doesn't really have an option to leave
them unannotated if they want the redefinition semantics. So we allow
redefinition but use type context behavior like for annotated variables.
cc @JukkaL
0 commit comments