Skip to content

Commit 2d8a808

Browse files
authored
Import Literal & TypedDict from the typing module (#1175)
* Import 'Literal' from the typing module * Import 'TypedDict' from the typing module
1 parent 98b9562 commit 2d8a808

File tree

9 files changed

+12
-29
lines changed

9 files changed

+12
-29
lines changed

babel/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import os
1414
import pickle
1515
from collections.abc import Iterable, Mapping
16-
from typing import TYPE_CHECKING, Any
16+
from typing import TYPE_CHECKING, Any, Literal
1717

1818
from babel import localedata
1919
from babel.plural import PluralRule
@@ -29,7 +29,7 @@
2929
]
3030

3131
if TYPE_CHECKING:
32-
from typing_extensions import Literal, TypeAlias
32+
from typing_extensions import TypeAlias
3333

3434
_GLOBAL_KEY: TypeAlias = Literal[
3535
"all_currencies",

babel/dates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import re
2222
import warnings
2323
from functools import lru_cache
24-
from typing import TYPE_CHECKING, SupportsInt
24+
from typing import TYPE_CHECKING, Literal, SupportsInt
2525

2626
try:
2727
import pytz
@@ -37,7 +37,7 @@
3737
from babel.localedata import LocaleDataDict
3838

3939
if TYPE_CHECKING:
40-
from typing_extensions import Literal, TypeAlias
40+
from typing_extensions import TypeAlias
4141
_Instant: TypeAlias = datetime.date | datetime.time | float | None
4242
_PredefinedTimeFormat: TypeAlias = Literal['full', 'long', 'medium', 'short']
4343
_Context: TypeAlias = Literal['format', 'stand-alone']

babel/lists.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,10 @@
1717

1818
import warnings
1919
from collections.abc import Sequence
20-
from typing import TYPE_CHECKING
20+
from typing import Literal
2121

2222
from babel.core import Locale, default_locale
2323

24-
if TYPE_CHECKING:
25-
from typing_extensions import Literal
26-
27-
28-
2924
_DEFAULT_LOCALE = default_locale() # TODO(3.0): Remove this.
3025

3126

babel/messages/extract.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from os.path import relpath
3535
from textwrap import dedent
3636
from tokenize import COMMENT, NAME, NL, OP, STRING, generate_tokens
37-
from typing import TYPE_CHECKING, Any
37+
from typing import TYPE_CHECKING, Any, TypedDict
3838

3939
from babel.messages._compat import find_entrypoints
4040
from babel.util import parse_encoding, parse_future_flags, pathmatch
@@ -43,7 +43,7 @@
4343
from typing import IO, Final, Protocol
4444

4545
from _typeshed import SupportsItems, SupportsRead, SupportsReadline
46-
from typing_extensions import TypeAlias, TypedDict
46+
from typing_extensions import TypeAlias
4747

4848
class _PyOptions(TypedDict, total=False):
4949
encoding: str

babel/messages/pofile.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import os
1414
import re
1515
from collections.abc import Iterable
16-
from typing import TYPE_CHECKING
16+
from typing import TYPE_CHECKING, Literal
1717

1818
from babel.core import Locale
1919
from babel.messages.catalog import Catalog, Message
@@ -23,7 +23,6 @@
2323
from typing import IO, AnyStr
2424

2525
from _typeshed import SupportsWrite
26-
from typing_extensions import Literal
2726

2827

2928
def unescape(string: str) -> str:

babel/numbers.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@
2323
import decimal
2424
import re
2525
import warnings
26-
from typing import TYPE_CHECKING, Any, cast, overload
26+
from typing import Any, Literal, cast, overload
2727

2828
from babel.core import Locale, default_locale, get_global
2929
from babel.localedata import LocaleDataDict
3030

31-
if TYPE_CHECKING:
32-
from typing_extensions import Literal
33-
3431
LC_NUMERIC = default_locale('LC_NUMERIC')
3532

3633

babel/plural.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
import decimal
1313
import re
1414
from collections.abc import Iterable, Mapping
15-
from typing import TYPE_CHECKING, Any, Callable
16-
17-
if TYPE_CHECKING:
18-
from typing_extensions import Literal
15+
from typing import Any, Callable, Literal
1916

2017
_plural_tags = ('zero', 'one', 'two', 'few', 'many', 'other')
2118
_fallback_tag = 'other'

babel/support.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import locale
1717
import os
1818
from collections.abc import Iterator
19-
from typing import TYPE_CHECKING, Any, Callable, Iterable
19+
from typing import TYPE_CHECKING, Any, Callable, Iterable, Literal
2020

2121
from babel.core import Locale
2222
from babel.dates import format_date, format_datetime, format_time, format_timedelta
@@ -33,8 +33,6 @@
3333
import datetime as _datetime
3434
from decimal import Decimal
3535

36-
from typing_extensions import Literal
37-
3836
from babel.dates import _PredefinedTimeFormat
3937

4038

babel/units.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
from __future__ import annotations
22

33
import decimal
4-
from typing import TYPE_CHECKING
4+
from typing import Literal
55

66
from babel.core import Locale
77
from babel.numbers import LC_NUMERIC, format_decimal
88

9-
if TYPE_CHECKING:
10-
from typing_extensions import Literal
11-
129

1310
class UnknownUnitError(ValueError):
1411
def __init__(self, unit: str, locale: Locale) -> None:

0 commit comments

Comments
 (0)