Removed legacy usage of Union[]

This commit is contained in:
2024-12-26 18:36:57 +01:00
parent 95d04308bd
commit aa2c778a6a
13 changed files with 128 additions and 149 deletions

View File

@@ -1,8 +1,6 @@
from pathlib import Path
from typing import Any, List, Union
from typing import Any, List
import pytest
from libbot.i18n import BotLocale
@@ -20,14 +18,12 @@ from libbot.i18n import BotLocale
def test_bot_locale_get(
key: str,
args: List[str],
locale: Union[str, None],
locale: str | None,
expected: Any,
bot_locale: BotLocale,
):
assert (
bot_locale._(key, *args, locale=locale)
if locale is not None
else bot_locale._(key, *args)
bot_locale._(key, *args, locale=locale) if locale is not None else bot_locale._(key, *args)
) == expected
@@ -39,9 +35,7 @@ def test_bot_locale_get(
("nested", ["callbacks", "default"], ["sure", "авжеж"]),
],
)
def test_i18n_in_all_locales(
key: str, args: List[str], expected: Any, bot_locale: BotLocale
):
def test_i18n_in_all_locales(key: str, args: List[str], expected: Any, bot_locale: BotLocale):
assert (bot_locale.in_all_locales(key, *args)) == expected
@@ -53,7 +47,5 @@ def test_i18n_in_all_locales(
("nested", ["callbacks", "default"], {"en": "sure", "uk": "авжеж"}),
],
)
def test_i18n_in_every_locale(
key: str, args: List[str], expected: Any, bot_locale: BotLocale
):
def test_i18n_in_every_locale(key: str, args: List[str], expected: Any, bot_locale: BotLocale):
assert (bot_locale.in_every_locale(key, *args)) == expected