Skip to content

Commit e193a26

Browse files
[flake8-pyi] Add checks for flake8-pyi and fix existing
1 parent 4eb246d commit e193a26

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ select = [
133133
"E", # pycodestyle
134134
"F", # pyflakes
135135
"I", # isort
136+
"PYI", # flake8-pyi
136137
"UP", # pyupgrade
137138
"RUF", # ruff
138139
"W", # pycodestyle

src/_pytest/capture.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,8 @@ class CaptureResult(NamedTuple, Generic[AnyStr]):
598598
else:
599599

600600
class CaptureResult(
601-
collections.namedtuple("CaptureResult", ["out", "err"]), Generic[AnyStr]
601+
collections.namedtuple("CaptureResult", ["out", "err"]), # noqa: PYI024
602+
Generic[AnyStr],
602603
):
603604
"""The result of :method:`caplog.readouterr() <pytest.CaptureFixture.readouterr>`."""
604605

src/_pytest/compat.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
from typing import Callable
1616
from typing import Final
1717
from typing import NoReturn
18-
from typing import TypeVar
19-
20-
21-
_T = TypeVar("_T")
22-
_S = TypeVar("_S")
2318

2419

2520
# fmt: off

testing/test_assertion.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# mypy: allow-untyped-defs
2-
import collections
32
import sys
43
import textwrap
54
from typing import Any
65
from typing import List
76
from typing import MutableSequence
7+
from typing import NamedTuple
88
from typing import Optional
99

1010
import attr
@@ -1179,7 +1179,9 @@ def __eq__(self, other): # pragma: no cover
11791179

11801180
class TestAssert_reprcompare_namedtuple:
11811181
def test_namedtuple(self) -> None:
1182-
NT = collections.namedtuple("NT", ["a", "b"])
1182+
class NT(NamedTuple):
1183+
a: Any
1184+
b: Any
11831185

11841186
left = NT(1, "b")
11851187
right = NT(1, "c")
@@ -1200,8 +1202,13 @@ def test_namedtuple(self) -> None:
12001202
]
12011203

12021204
def test_comparing_two_different_namedtuple(self) -> None:
1203-
NT1 = collections.namedtuple("NT1", ["a", "b"])
1204-
NT2 = collections.namedtuple("NT2", ["a", "b"])
1205+
class NT1(NamedTuple):
1206+
a: Any
1207+
b: Any
1208+
1209+
class NT2(NamedTuple):
1210+
a: Any
1211+
b: Any
12051212

12061213
left = NT1(1, "b")
12071214
right = NT2(2, "b")

testing/test_terminal.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# mypy: allow-untyped-defs
22
"""Terminal reporting of the full testing process."""
3-
import collections
43
from io import StringIO
54
import os
65
from pathlib import Path
@@ -10,6 +9,7 @@
109
from typing import cast
1110
from typing import Dict
1211
from typing import List
12+
from typing import NamedTuple
1313
from typing import Tuple
1414

1515
import pluggy
@@ -34,7 +34,9 @@
3434
import pytest
3535

3636

37-
DistInfo = collections.namedtuple("DistInfo", ["project_name", "version"])
37+
class DistInfo(NamedTuple):
38+
project_name: str
39+
version: int
3840

3941

4042
TRANS_FNMATCH = str.maketrans({"[": "[[]", "]": "[]]"})

0 commit comments

Comments
 (0)