Skip to content

Commit 7ce4607

Browse files
authored
Upgrade flake8-pyi to 22.4.0, enable Y026 in .flake8 config (#7650)
1 parent 145a853 commit 7ce4607

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

.flake8

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# F405 defined from star imports
1919

2020
# Rules that we'd like to enable in the future:
21-
# Y026 Use typing_extensions.TypeAlias for type aliases (blocked by #4913)
2221
# Y027 Disallow importing typing.ContextManager, typing.OrderedDict &
2322
# typing_extensions.OrderedDict (cannot be globally enabled while typeshed
2423
# still contains stubs supporting Python 2).
@@ -32,12 +31,12 @@
3231
[flake8]
3332
per-file-ignores =
3433
*.py: E203, E501
35-
*.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F822, Y026, Y037
34+
*.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F822, Y037
3635
# Since typing.pyi defines "overload" this is not recognized by flake8 as typing.overload.
3736
# Unfortunately, flake8 does not allow to "noqa" just a specific error inside the file itself.
3837
# https://github.com/PyCQA/flake8/issues/1079
3938
# F811 redefinition of unused '...'
40-
stubs/*.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F822, Y026, Y027, Y037
41-
stdlib/typing.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F811, F822, Y026, Y034, Y037
39+
stubs/*.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F822, Y027, Y037
40+
stdlib/typing.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F811, F822, Y034, Y037
4241

4342
exclude = .venv*,.git,*_pb2.pyi,stdlib/@python2/*

requirements-tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pytype==2022.03.29; platform_system != "Windows" and python_version < "3.10"
44
black==22.3.0
55
flake8==4.0.1
66
flake8-bugbear==21.11.29
7-
flake8-pyi==22.3.0
7+
flake8-pyi==22.4.0
88
# must match .pre-commit-config.yaml
99
isort==5.10.1
1010
tomli==1.2.2

stdlib/builtins.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ def next(__i: SupportsNext[_T]) -> _T: ...
12891289
def next(__i: SupportsNext[_T], __default: _VT) -> _T | _VT: ...
12901290
def oct(__number: int | SupportsIndex) -> str: ...
12911291

1292-
_OpenFile = StrOrBytesPath | int
1292+
_OpenFile = StrOrBytesPath | int # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
12931293
_Opener: TypeAlias = Callable[[str, int], int]
12941294

12951295
# Text mode: always returns a TextIOWrapper
@@ -1408,7 +1408,9 @@ class _SupportsPow3NoneOnly(Protocol[_E, _T_co]):
14081408
class _SupportsPow3(Protocol[_E, _M, _T_co]):
14091409
def __pow__(self, __other: _E, __modulo: _M) -> _T_co: ...
14101410

1411-
_SupportsSomeKindOfPow = _SupportsPow2[Any, Any] | _SupportsPow3NoneOnly[Any, Any] | _SupportsPow3[Any, Any, Any]
1411+
_SupportsSomeKindOfPow = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
1412+
_SupportsPow2[Any, Any] | _SupportsPow3NoneOnly[Any, Any] | _SupportsPow3[Any, Any, Any]
1413+
)
14121414

14131415
if sys.version_info >= (3, 8):
14141416
@overload

stdlib/typing.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ class Pattern(Generic[AnyStr]):
11461146
# Functions
11471147

11481148
if sys.version_info >= (3, 7):
1149-
_get_type_hints_obj_allowed_types = (
1149+
_get_type_hints_obj_allowed_types = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
11501150
object
11511151
| Callable[..., Any]
11521152
| FunctionType
@@ -1158,7 +1158,9 @@ if sys.version_info >= (3, 7):
11581158
| MethodDescriptorType
11591159
)
11601160
else:
1161-
_get_type_hints_obj_allowed_types = object | Callable[..., Any] | FunctionType | BuiltinFunctionType | MethodType | ModuleType
1161+
_get_type_hints_obj_allowed_types = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
1162+
object | Callable[..., Any] | FunctionType | BuiltinFunctionType | MethodType | ModuleType
1163+
)
11621164

11631165
if sys.version_info >= (3, 9):
11641166
def get_type_hints(

0 commit comments

Comments
 (0)