Removed legacy usage of Union[]
This commit is contained in:
@@ -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
|
||||
|
@@ -1,8 +1,7 @@
|
||||
from pathlib import Path
|
||||
from typing import Any, List, Union
|
||||
from typing import Any, List
|
||||
|
||||
import pytest
|
||||
|
||||
from libbot import i18n
|
||||
|
||||
|
||||
@@ -21,7 +20,7 @@ from libbot import i18n
|
||||
async def test_i18n_get(
|
||||
key: str,
|
||||
args: List[str],
|
||||
locale: Union[str, None],
|
||||
locale: str | None,
|
||||
expected: Any,
|
||||
location_locale: Path,
|
||||
):
|
||||
@@ -41,12 +40,8 @@ async def test_i18n_get(
|
||||
("nested", ["callbacks", "default"], ["sure", "авжеж"]),
|
||||
],
|
||||
)
|
||||
async def test_i18n_in_all_locales(
|
||||
key: str, args: List[str], expected: Any, location_locale: Path
|
||||
):
|
||||
assert (
|
||||
await i18n.in_all_locales(key, *args, locales_root=location_locale)
|
||||
) == expected
|
||||
async def test_i18n_in_all_locales(key: str, args: List[str], expected: Any, location_locale: Path):
|
||||
assert (await i18n.in_all_locales(key, *args, locales_root=location_locale)) == expected
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -58,9 +53,5 @@ async def test_i18n_in_all_locales(
|
||||
("nested", ["callbacks", "default"], {"en": "sure", "uk": "авжеж"}),
|
||||
],
|
||||
)
|
||||
async def test_i18n_in_every_locale(
|
||||
key: str, args: List[str], expected: Any, location_locale: Path
|
||||
):
|
||||
assert (
|
||||
await i18n.in_every_locale(key, *args, locales_root=location_locale)
|
||||
) == expected
|
||||
async def test_i18n_in_every_locale(key: str, args: List[str], expected: Any, location_locale: Path):
|
||||
assert (await i18n.in_every_locale(key, *args, locales_root=location_locale)) == expected
|
||||
|
@@ -1,5 +1,5 @@
|
||||
from pathlib import Path
|
||||
from typing import Any, List, Union
|
||||
from typing import Any, List
|
||||
|
||||
import pytest
|
||||
from libbot.i18n import _, in_all_locales, in_every_locale
|
||||
@@ -19,7 +19,7 @@ from libbot.i18n import _, in_all_locales, in_every_locale
|
||||
def test_i18n_get(
|
||||
key: str,
|
||||
args: List[str],
|
||||
locale: Union[str, None],
|
||||
locale: str | None,
|
||||
expected: Any,
|
||||
location_locale: Path,
|
||||
):
|
||||
|
@@ -4,7 +4,7 @@ except ImportError:
|
||||
from json import dumps, JSONDecodeError
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Union
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from libbot.utils import json_read, json_write
|
||||
@@ -24,7 +24,7 @@ from libbot.utils import json_read, json_write
|
||||
("tests/data/empty.json", {}),
|
||||
],
|
||||
)
|
||||
async def test_json_read_valid(path: Union[str, Path], expected: Any):
|
||||
async def test_json_read_valid(path: str | Path, expected: Any):
|
||||
assert await json_read(path) == expected
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ async def test_json_read_valid(path: Union[str, Path], expected: Any):
|
||||
("tests/data/nonexistent.json", FileNotFoundError),
|
||||
],
|
||||
)
|
||||
async def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
||||
async def test_json_read_invalid(path: str | Path, expected: Any):
|
||||
with pytest.raises(expected):
|
||||
await json_read(path)
|
||||
|
||||
@@ -55,7 +55,7 @@ async def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
||||
({}, "tests/data/empty.json"),
|
||||
],
|
||||
)
|
||||
async def test_json_write(data: Any, path: Union[str, Path]):
|
||||
async def test_json_write(data: Any, path: str | Path):
|
||||
await json_write(data, path)
|
||||
|
||||
assert Path(path).is_file()
|
||||
|
@@ -4,7 +4,7 @@ except ImportError:
|
||||
from json import dumps, JSONDecodeError
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Union
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from libbot.utils import json_read, json_write
|
||||
@@ -23,7 +23,7 @@ from libbot.utils import json_read, json_write
|
||||
("tests/data/empty.json", {}),
|
||||
],
|
||||
)
|
||||
def test_json_read_valid(path: Union[str, Path], expected: Any):
|
||||
def test_json_read_valid(path: str | Path, expected: Any):
|
||||
assert json_read(path) == expected
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_json_read_valid(path: Union[str, Path], expected: Any):
|
||||
("tests/data/nonexistent.json", FileNotFoundError),
|
||||
],
|
||||
)
|
||||
def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
||||
def test_json_read_invalid(path: str | Path, expected: Any):
|
||||
with pytest.raises(expected):
|
||||
assert json_read(path) == expected
|
||||
|
||||
@@ -52,7 +52,7 @@ def test_json_read_invalid(path: Union[str, Path], expected: Any):
|
||||
({}, "tests/data/empty.json"),
|
||||
],
|
||||
)
|
||||
def test_json_write(data: Any, path: Union[str, Path]):
|
||||
def test_json_write(data: Any, path: str | Path):
|
||||
json_write(data, path)
|
||||
|
||||
assert Path(path).is_file()
|
||||
|
Reference in New Issue
Block a user