From 674a8628a357f2083806db3b33cba7a711ec0803 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Mon, 25 Jul 2022 14:42:21 +0100 Subject: [PATCH] Update crowdin script to use suffixed overloads. --- scripts/crowdin_convert.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/crowdin_convert.py b/scripts/crowdin_convert.py index 3a535e7..70baf30 100644 --- a/scripts/crowdin_convert.py +++ b/scripts/crowdin_convert.py @@ -271,9 +271,14 @@ def handle_docstring(self, node: ast.AST, name: str) -> None: key_root = ".".join([*self.key, name]) key = key_root suffix = 1 - while key in self.used_keys: - key = f"{key_root}-{suffix}" - suffix += 1 + if isinstance(node, ast.FunctionDef): # ctx.id + for decorator in node.decorator_list: + if hasattr(decorator, "id"): + if decorator.id == "overload": + key = f"{key}-{suffix}" + while key in self.used_keys: + suffix += 1 + key = f"{key_root}-{suffix}" self.used_keys.add(key) update_docstring(node, key, en_json, translated_json)