chore: adhere to ruff's UP
basically use `list` and `type` instead of `List` and `Type` this is save to use for python3.9 and has been deprecated. also has some performance drawbacks. read more here: https://docs.astral.sh/ruff/rules/non-pep585-annotation/
This commit is contained in:
parent
a158056b99
commit
b145bff566
12 changed files with 54 additions and 52 deletions
|
|
@ -17,7 +17,7 @@ assert os.getenv("OPENAI_API_KEY"), "OPENAI_API_KEY env var not set"
|
|||
|
||||
|
||||
def load_language(lang: str) -> dict:
|
||||
s = open(f"lnbits/static/i18n/{lang}.js", "rt").read()
|
||||
s = open(f"lnbits/static/i18n/{lang}.js").read()
|
||||
prefix = "window.localisation.%s = {\n" % lang
|
||||
assert s.startswith(prefix)
|
||||
s = s[len(prefix) - 2 :]
|
||||
|
|
@ -27,7 +27,7 @@ def load_language(lang: str) -> dict:
|
|||
|
||||
|
||||
def save_language(lang: str, data) -> None:
|
||||
with open(f"lnbits/static/i18n/{lang}.js", "wt") as f:
|
||||
with open(f"lnbits/static/i18n/{lang}.js", "w") as f:
|
||||
f.write("window.localisation.%s = {\n" % lang)
|
||||
row = 0
|
||||
for k, v in data.items():
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ def get_translation_ids_from_source():
|
|||
p2 = re.compile(r'\$t\("([^"]*)"')
|
||||
ids = []
|
||||
for fn in files:
|
||||
with open(fn, "rt") as f:
|
||||
with open(fn) as f:
|
||||
text = f.read()
|
||||
m1 = re.findall(p1, text)
|
||||
m2 = re.findall(p2, text)
|
||||
|
|
@ -30,7 +30,7 @@ def get_translation_ids_from_source():
|
|||
|
||||
def get_translation_ids_for_language(language):
|
||||
ids = []
|
||||
for line in open(f"lnbits/static/i18n/{language}.js", "rt"):
|
||||
for line in open(f"lnbits/static/i18n/{language}.js"):
|
||||
# extract ids from lines like that start with exactly 2 spaces
|
||||
if line.startswith(" ") and not line.startswith(" "):
|
||||
m = line[2:].split(":")[0]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue