Skip to content

Commit c626137

Browse files
authored
Always use bool and Literal for Python compat code (#9213)
1 parent 9137258 commit c626137

File tree

8 files changed

+30
-23
lines changed

8 files changed

+30
-23
lines changed

stubs/SQLAlchemy/sqlalchemy/util/compat.pyi

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ from io import BytesIO as BytesIO, StringIO as StringIO
1212
from itertools import zip_longest as zip_longest
1313
from time import perf_counter as perf_counter
1414
from typing import TYPE_CHECKING as TYPE_CHECKING, Any, NamedTuple
15+
from typing_extensions import Literal
1516
from urllib.parse import (
1617
parse_qsl as parse_qsl,
1718
quote as quote,
@@ -22,17 +23,17 @@ from urllib.parse import (
2223

2324
byte_buffer = BytesIO
2425

25-
py39: Any
26-
py38: Any
27-
py37: Any
28-
py3k: Any
29-
py2k: Any
30-
pypy: Any
31-
cpython: Any
32-
win32: Any
33-
osx: Any
34-
arm: Any
35-
has_refcount_gc: Any
26+
py39: bool
27+
py38: bool
28+
py37: bool
29+
py3k: Literal[True]
30+
py2k: Literal[False]
31+
pypy: bool
32+
cpython: bool
33+
win32: bool
34+
osx: bool
35+
arm: bool
36+
has_refcount_gc: bool
3637
contextmanager = contextlib.contextmanager
3738
dottedgetter = operator.attrgetter
3839
namedtuple = collections.namedtuple # noqa: Y024
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any
2+
from typing_extensions import Literal
23

3-
PY3: Any
4+
PY3: Literal[True]
45
text_type = str
56
binary_type = bytes
67
environb: Any

stubs/appdirs/appdirs.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from typing_extensions import Literal
2+
13
__version_info__: tuple[int, int, int]
2-
PY3: bool
4+
PY3: Literal[True]
35
unicode = str
46
system: str
57

stubs/aws-xray-sdk/aws_xray_sdk/core/utils/compat.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from typing import Any
2+
from typing_extensions import Literal
23

3-
PY2: Any
4-
PY35: Any
4+
PY2: Literal[False]
5+
PY35: Literal[True]
56
annotation_value_types: Any
67
string_types = str
78

stubs/pyinstaller/PyInstaller/compat.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ from typing_extensions import Literal, TypeAlias
88
_OpenFile: TypeAlias = StrOrBytesPath | FileDescriptor
99

1010
is_64bits: bool
11-
is_py35: bool
12-
is_py36: bool
11+
is_py35: Literal[True]
12+
is_py36: Literal[True]
1313
is_py37: bool
1414
is_py38: bool
1515
is_py39: bool

stubs/python-crontab/crontab.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ from collections.abc import Callable, Generator
66
from logging import Logger
77
from types import TracebackType
88
from typing import Any
9+
from typing_extensions import Literal
910

1011
__pkgname__: str
1112
ITEMREX: re.Pattern[str]
@@ -16,7 +17,7 @@ MONTH_ENUM: list[str | None]
1617
SPECIALS: dict[str, str]
1718
SPECIAL_IGNORE: list[str]
1819
S_INFO: list[dict[str, Any]]
19-
PY3: bool
20+
PY3: Literal[True]
2021
WINOS: bool
2122
POSIX: bool
2223
SYSTEMV: bool

stubs/requests/requests/compat.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from builtins import bytes as bytes, str as str
22
from collections import OrderedDict as OrderedDict
3-
from typing_extensions import TypeAlias
3+
from typing_extensions import Literal, TypeAlias
44
from urllib.parse import (
55
quote as quote,
66
quote_plus as quote_plus,
@@ -15,8 +15,8 @@ from urllib.parse import (
1515
)
1616
from urllib.request import getproxies as getproxies, parse_http_list as parse_http_list, proxy_bypass as proxy_bypass
1717

18-
is_py2: bool
19-
is_py3: bool
18+
is_py2: Literal[False]
19+
is_py3: Literal[True]
2020
has_simplejson: bool
2121

2222
builtin_str: TypeAlias = str # noqa: Y042

stubs/waitress/waitress/compat.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from io import TextIOWrapper
22
from typing import Any
3+
from typing_extensions import Literal
34

4-
PY2: bool
5-
PY3: bool
5+
PY2: Literal[False]
6+
PY3: Literal[True]
67
WIN: bool
78
string_types: tuple[str]
89
integer_types: tuple[int]

0 commit comments

Comments
 (0)