Uh oh!
There was an error while loading. Please reload this page.
gettext: fix unconstrained TypeVar - #7935
Conversation
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
AlexWaygood
left a comment
There was a problem hiding this comment.
Looking at the 3.11 branch: which calls will be incorrectly inferred (or incorrectly disallowed) if we omit overloads 2-4 here? Could we not just do the following, using only 4 overloads instead of 7?
Overloads 2 and 3
These are the Literal[True] overloads, but they're covered by the final bool fallback overload, since the return type is the same.
Overload 4
This can be combined with the final fallback overload, since the return type is the same. For the final overload, we can just have the class_ parameter as Callable[[io.BufferedReader], _T] | None instead of Callable[[io.BufferedReader], _T].
@overloaddeftranslation(
domain: str,
localedir: StrPath|None= ...,
languages: Iterable[str] |None= ...,
class_: None= ...,
fallback: Literal[False] = ...,
) ->GNUTranslations: ...
@overloaddeftranslation(
domain: str,
localedir: StrPath|None= ...,
languages: Iterable[str] |None= ...,
*,
class_: Callable[[io.BufferedReader], _T],
fallback: Literal[False] = ...,
) ->_T: ...
@overloaddeftranslation(
domain: str,
localedir: StrPath|None,
languages: Iterable[str] |None,
class_: Callable[[io.BufferedReader], _T],
fallback: Literal[False] = ...,
) ->_T: ...
@overloaddeftranslation(
domain: str,
localedir: StrPath|None= ...,
languages: Iterable[str] |None= ...,
class_: Callable[[io.BufferedReader], NullTranslations] |None= ...,
fallback: bool= ...,
) ->NullTranslations: ...It might also be good to rename the |
JelleZijlstra
commented
May 26, 2022
Good point, you're right. |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Part of #7928