]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Import `Literal` & `TypedDict` from the typing module (#1175)
authorTomas R. <tomas.roun8@gmail.com>
Sat, 25 Jan 2025 08:48:00 +0000 (09:48 +0100)
committerGitHub <noreply@github.com>
Sat, 25 Jan 2025 08:48:00 +0000 (10:48 +0200)
* Import 'Literal' from the typing module
* Import 'TypedDict' from the typing module

babel/core.py
babel/dates.py
babel/lists.py
babel/messages/extract.py
babel/messages/pofile.py
babel/numbers.py
babel/plural.py
babel/support.py
babel/units.py

index 39a2cf6eddafb34289a3f85006a8ad8c8a5bfab3..1c7732b5378bd715d73886d77f2ee7638c93acd8 100644 (file)
@@ -13,7 +13,7 @@ from __future__ import annotations
 import os
 import pickle
 from collections.abc import Iterable, Mapping
-from typing import TYPE_CHECKING, Any
+from typing import TYPE_CHECKING, Any, Literal
 
 from babel import localedata
 from babel.plural import PluralRule
@@ -29,7 +29,7 @@ __all__ = [
 ]
 
 if TYPE_CHECKING:
-    from typing_extensions import Literal, TypeAlias
+    from typing_extensions import TypeAlias
 
     _GLOBAL_KEY: TypeAlias = Literal[
         "all_currencies",
index 98dd3f044ba63de865bf23089f7452590b141ce1..8a4932d4bca2c3fea5e6f5cf9b90064b6475d561 100644 (file)
@@ -21,7 +21,7 @@ import math
 import re
 import warnings
 from functools import lru_cache
-from typing import TYPE_CHECKING, SupportsInt
+from typing import TYPE_CHECKING, Literal, SupportsInt
 
 try:
     import pytz
@@ -37,7 +37,7 @@ from babel.core import Locale, default_locale, get_global
 from babel.localedata import LocaleDataDict
 
 if TYPE_CHECKING:
-    from typing_extensions import Literal, TypeAlias
+    from typing_extensions import TypeAlias
     _Instant: TypeAlias = datetime.date | datetime.time | float | None
     _PredefinedTimeFormat: TypeAlias = Literal['full', 'long', 'medium', 'short']
     _Context: TypeAlias = Literal['format', 'stand-alone']
index f1d3790d18244ff6c0f7b31d39a819e56a491fd4..103a17713854ba956cc13fa73e4da080865c84ac 100644 (file)
@@ -17,15 +17,10 @@ from __future__ import annotations
 
 import warnings
 from collections.abc import Sequence
-from typing import TYPE_CHECKING
+from typing import Literal
 
 from babel.core import Locale, default_locale
 
-if TYPE_CHECKING:
-    from typing_extensions import Literal
-
-
-
 _DEFAULT_LOCALE = default_locale()  # TODO(3.0): Remove this.
 
 
index 1c86e4ac8512a3824a9a3f60626093a2fd6d6c2f..6dd0313822a3381c33d0d992d9a0d53dd4eda69c 100644 (file)
@@ -34,7 +34,7 @@ from functools import lru_cache
 from os.path import relpath
 from textwrap import dedent
 from tokenize import COMMENT, NAME, NL, OP, STRING, generate_tokens
-from typing import TYPE_CHECKING, Any
+from typing import TYPE_CHECKING, Any, TypedDict
 
 from babel.messages._compat import find_entrypoints
 from babel.util import parse_encoding, parse_future_flags, pathmatch
@@ -43,7 +43,7 @@ if TYPE_CHECKING:
     from typing import IO, Final, Protocol
 
     from _typeshed import SupportsItems, SupportsRead, SupportsReadline
-    from typing_extensions import TypeAlias, TypedDict
+    from typing_extensions import TypeAlias
 
     class _PyOptions(TypedDict, total=False):
         encoding: str
index a292c8a0c261620668673f8d670f93094287821a..ad9b07ad0e5524c9738075e1eec71a12f3a237db 100644 (file)
@@ -13,7 +13,7 @@ from __future__ import annotations
 import os
 import re
 from collections.abc import Iterable
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Literal
 
 from babel.core import Locale
 from babel.messages.catalog import Catalog, Message
@@ -23,7 +23,6 @@ if TYPE_CHECKING:
     from typing import IO, AnyStr
 
     from _typeshed import SupportsWrite
-    from typing_extensions import Literal
 
 
 def unescape(string: str) -> str:
index 6d334918aa809c4ef2cebf97202332354f410c02..a2b89cc315386cebfe0bee2d1a1c74a6f2a7a823 100644 (file)
@@ -23,14 +23,11 @@ import datetime
 import decimal
 import re
 import warnings
-from typing import TYPE_CHECKING, Any, cast, overload
+from typing import Any, Literal, cast, overload
 
 from babel.core import Locale, default_locale, get_global
 from babel.localedata import LocaleDataDict
 
-if TYPE_CHECKING:
-    from typing_extensions import Literal
-
 LC_NUMERIC = default_locale('LC_NUMERIC')
 
 
index 528d4175ea8d7a8c5bf1f528f4c157330ecdcfcb..a2e30f456c8ca352b6c2202750b3ca7c7ec6b36e 100644 (file)
@@ -12,10 +12,7 @@ from __future__ import annotations
 import decimal
 import re
 from collections.abc import Iterable, Mapping
-from typing import TYPE_CHECKING, Any, Callable
-
-if TYPE_CHECKING:
-    from typing_extensions import Literal
+from typing import Any, Callable, Literal
 
 _plural_tags = ('zero', 'one', 'two', 'few', 'many', 'other')
 _fallback_tag = 'other'
index ad9582809726464f3be8e1800140d2f304e95873..4374a0ce006769ee4adddf3cc1be948d9fd075e8 100644 (file)
@@ -16,7 +16,7 @@ import gettext
 import locale
 import os
 from collections.abc import Iterator
-from typing import TYPE_CHECKING, Any, Callable, Iterable
+from typing import TYPE_CHECKING, Any, Callable, Iterable, Literal
 
 from babel.core import Locale
 from babel.dates import format_date, format_datetime, format_time, format_timedelta
@@ -33,8 +33,6 @@ if TYPE_CHECKING:
     import datetime as _datetime
     from decimal import Decimal
 
-    from typing_extensions import Literal
-
     from babel.dates import _PredefinedTimeFormat
 
 
index d7d5e84f534b9e4ba34bdf6da5623718304656bb..86ac2abc9ac52aa055cc363ead8def53d04a8958 100644 (file)
@@ -1,14 +1,11 @@
 from __future__ import annotations
 
 import decimal
-from typing import TYPE_CHECKING
+from typing import Literal
 
 from babel.core import Locale
 from babel.numbers import LC_NUMERIC, format_decimal
 
-if TYPE_CHECKING:
-    from typing_extensions import Literal
-
 
 class UnknownUnitError(ValueError):
     def __init__(self, unit: str, locale: Locale) -> None: