diff --git a/src/xpuz/base.py b/src/xpuz/base.py index eae6669b..51536808 100644 --- a/src/xpuz/base.py +++ b/src/xpuz/base.py @@ -4,7 +4,11 @@ from configparser import ConfigParser from platform import system -from typing import Dict, List, Union, Tuple, Callable, Literal +from typing import Dict, List, Union, Tuple, Callable +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal from babel import Locale from customtkinter import ( diff --git a/src/xpuz/constants.py b/src/xpuz/constants.py index aebd37de..54ba8bb6 100644 --- a/src/xpuz/constants.py +++ b/src/xpuz/constants.py @@ -37,14 +37,11 @@ LANG_REPLACEMENTS: Mapping of google translate language codes to their respective `Babel` language codes. `None` if they do not exist, otherwise, a string representing the `Babel`-correct code. - - - """ from os import path -from pathlib import Path, PosixPath, WindowsPath -from typing import Dict, List, Union +from pathlib import Path +from typing import Dict, List, Union, Tuple from platformdirs import user_documents_dir from regex import Pattern, compile @@ -92,7 +89,7 @@ class Dark: # Absolute paths used across the source code. -DIR_PATH: Union[PosixPath, WindowsPath] = Path(__file__).resolve().parents[0] +DIR_PATH: Path = Path(__file__).resolve().parents[0] TEMPLATE_CFG_PATH: str = path.join(DIR_PATH, "template.config.ini") DOC_PATH: str = user_documents_dir() DOC_DATA_PATH: str = path.join(DOC_PATH, "xpuz") diff --git a/src/xpuz/utils.py b/src/xpuz/utils.py index 55f09c38..b5826c8c 100644 --- a/src/xpuz/utils.py +++ b/src/xpuz/utils.py @@ -18,9 +18,12 @@ Optional, Tuple, Union, - Literal, Any, ) +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal from urllib.error import URLError from babel import Locale