Skip to content

Commit a0a70e3

Browse files
committed
Make untranslated a positional-only argument in Translator().
This commit changes the signature of `redbot.core.i18n.Translator.__call__()` from `self, untranslated: str` to `self, untranslated: str, /`, making `untranslated` a positional-only argument. This works around an issue in `redgettext`, where using `_("text")` works fine, but `_(untranslated="text")` causes `untranslated=` to be detected as an unexpected token. Considering this function is a single-argument function, and nothing would be gained from using the keyword argument, I believe marking it as positional-only is the correct solution, rather than making a change in `redgettext`. This is technically a breaking change though. This also has the small but notable side effect of removing `untranslated=` from calls in editors that show inline keyword arguments, such as basedpyright's `basedpyright.analysis.inlayHints.callArgumentNames` VSCode setting, or similar settings in other extensions. This cuts down on wasted space in the editor without disabling an otherwise useful feature. See the related discussion in [`#coding`](https://discord.com/channels/133049272517001216/160386989819035648/1453030635756191866).
1 parent dd3b9a0 commit a0a70e3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

redbot/core/i18n.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def __init__(self, name: str, file_location: Union[str, Path, os.PathLike]):
279279

280280
self.load_translations()
281281

282-
def __call__(self, untranslated: str) -> str:
282+
def __call__(self, untranslated: str, /) -> str:
283283
"""Translate the given string.
284284
285285
This will look for the string in the translator's :code:`.pot` file,

0 commit comments

Comments
 (0)