From 3fd2abc1f9b614c292023bfb15d9cd6692473c49 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Mon, 30 Oct 2023 00:20:11 -0400 Subject: [PATCH] Run ruff --- libretranslate/detect.py | 10 +++++----- libretranslate/language.py | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libretranslate/detect.py b/libretranslate/detect.py index 559aea8..b1bafa8 100644 --- a/libretranslate/detect.py +++ b/libretranslate/detect.py @@ -1,15 +1,15 @@ -import linguars from functools import lru_cache +import linguars + + class Language: def __init__(self, code, confidence): self.code = code self.confidence = float(confidence) def __str__(self): - return ("code: {:<9} confidence: {:>5.1f} ".format( - self.code, - self.confidence)) + return (f"code: {self.code:<9} confidence: {self.confidence:>5.1f} ") @lru_cache(maxsize=None) def load_detector(langcodes = ()): @@ -17,7 +17,7 @@ def load_detector(langcodes = ()): for lc in langcodes: try: languages.append(linguars.Language.from_iso_code_639_1(lc)) - except Exception as e: + except Exception: print(f"{lc} is not supported by lingua") pass # Not supported diff --git a/libretranslate/language.py b/libretranslate/language.py index cc647b1..7d1ea2c 100644 --- a/libretranslate/language.py +++ b/libretranslate/language.py @@ -1,6 +1,7 @@ +from functools import lru_cache + from argostranslate import translate -from functools import lru_cache from libretranslate.detect import Detector