Sfoglia il codice sorgente

ci (untranslated_entities): warn when name is same as translation

Warnings were suppressed for all entities with a translation_key
already, but a translation_key with a name that is the same should
also be warned about.

Warning is still suppressed when they differ, as there might be a
good reason to use a different key than that matching the name.
Jason Rumney 2 giorni fa
parent
commit
4f3bd1208f
1 ha cambiato i file con 5 aggiunte e 6 eliminazioni
  1. 5 6
      util/untranslated_entities.py

+ 5 - 6
util/untranslated_entities.py

@@ -18,14 +18,13 @@ def main() -> int:
     for config in available_configs():
         device = TuyaDeviceConfig(config)
         for entity in device.all_entities():
-            if (
-                entity.translation_key
-                or entity.name is None
-                or entity.entity not in english["entity"]
-            ):
+            if entity.name is None or entity.entity not in english["entity"]:
                 continue
-            translations = english["entity"][entity.entity]
             slug = slugify(entity.name)
+
+            if entity.translation_key and slug != entity.translation_key:
+                continue
+            translations = english["entity"][entity.entity]
             if slug in translations:
                 print(
                     f"::error file=custom_components/tuya_local/devices/{config},line={entity._config.__line__}:: Entity can use translation_key: {slug}"