Skip to content

Commit 2c7b7d8

Browse files
authored
Merge pull request #7836 from asottile/py36_typing_X
py36+: replace typing.X with X
2 parents ac18988 + cf220b9 commit 2c7b7d8

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

src/_pytest/mark/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Generic mechanism for marking and selecting python functions."""
2-
import typing
32
import warnings
43
from typing import AbstractSet
4+
from typing import Collection
55
from typing import List
66
from typing import Optional
77
from typing import TYPE_CHECKING
@@ -46,7 +46,7 @@
4646

4747
def param(
4848
*values: object,
49-
marks: "Union[MarkDecorator, typing.Collection[Union[MarkDecorator, Mark]]]" = (),
49+
marks: Union[MarkDecorator, Collection[Union[MarkDecorator, Mark]]] = (),
5050
id: Optional[str] = None
5151
) -> ParameterSet:
5252
"""Specify a parameter in `pytest.mark.parametrize`_ calls or

src/_pytest/mark/structures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import collections.abc
22
import inspect
3-
import typing
43
import warnings
54
from typing import Any
65
from typing import Callable
6+
from typing import Collection
77
from typing import Iterable
88
from typing import Iterator
99
from typing import List
@@ -79,7 +79,7 @@ class ParameterSet(
7979
"ParameterSet",
8080
[
8181
("values", Sequence[Union[object, NotSetType]]),
82-
("marks", "typing.Collection[Union[MarkDecorator, Mark]]"),
82+
("marks", Collection[Union["MarkDecorator", "Mark"]]),
8383
("id", Optional[str]),
8484
],
8585
)
@@ -88,7 +88,7 @@ class ParameterSet(
8888
def param(
8989
cls,
9090
*values: object,
91-
marks: "Union[MarkDecorator, typing.Collection[Union[MarkDecorator, Mark]]]" = (),
91+
marks: Union["MarkDecorator", Collection[Union["MarkDecorator", "Mark"]]] = (),
9292
id: Optional[str] = None
9393
) -> "ParameterSet":
9494
if isinstance(marks, MarkDecorator):

src/_pytest/python.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
import os
77
import sys
88
import types
9-
import typing
109
import warnings
1110
from collections import Counter
1211
from collections import defaultdict
13-
from collections.abc import Sequence
1412
from functools import partial
1513
from typing import Any
1614
from typing import Callable
@@ -21,6 +19,7 @@
2119
from typing import List
2220
from typing import Mapping
2321
from typing import Optional
22+
from typing import Sequence
2423
from typing import Set
2524
from typing import Tuple
2625
from typing import TYPE_CHECKING
@@ -668,7 +667,7 @@ def _recurse(self, direntry: "os.DirEntry[str]") -> bool:
668667

669668
def _collectfile(
670669
self, path: py.path.local, handle_dupes: bool = True
671-
) -> typing.Sequence[nodes.Collector]:
670+
) -> Sequence[nodes.Collector]:
672671
assert (
673672
path.isfile()
674673
), "{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})".format(
@@ -904,7 +903,7 @@ def id(self) -> str:
904903
def setmulti2(
905904
self,
906905
valtypes: Mapping[str, "Literal['params', 'funcargs']"],
907-
argnames: typing.Sequence[str],
906+
argnames: Sequence[str],
908907
valset: Iterable[object],
909908
id: str,
910909
marks: Iterable[Union[Mark, MarkDecorator]],
@@ -966,8 +965,8 @@ def __init__(
966965
def parametrize(
967966
self,
968967
argnames: Union[str, List[str], Tuple[str, ...]],
969-
argvalues: Iterable[Union[ParameterSet, typing.Sequence[object], object]],
970-
indirect: Union[bool, typing.Sequence[str]] = False,
968+
argvalues: Iterable[Union[ParameterSet, Sequence[object], object]],
969+
indirect: Union[bool, Sequence[str]] = False,
971970
ids: Optional[
972971
Union[
973972
Iterable[Union[None, str, float, int, bool]],
@@ -1093,14 +1092,14 @@ def parametrize(
10931092

10941093
def _resolve_arg_ids(
10951094
self,
1096-
argnames: typing.Sequence[str],
1095+
argnames: Sequence[str],
10971096
ids: Optional[
10981097
Union[
10991098
Iterable[Union[None, str, float, int, bool]],
11001099
Callable[[Any], Optional[object]],
11011100
]
11021101
],
1103-
parameters: typing.Sequence[ParameterSet],
1102+
parameters: Sequence[ParameterSet],
11041103
nodeid: str,
11051104
) -> List[str]:
11061105
"""Resolve the actual ids for the given argnames, based on the ``ids`` parameter given
@@ -1127,7 +1126,7 @@ def _resolve_arg_ids(
11271126
def _validate_ids(
11281127
self,
11291128
ids: Iterable[Union[None, str, float, int, bool]],
1130-
parameters: typing.Sequence[ParameterSet],
1129+
parameters: Sequence[ParameterSet],
11311130
func_name: str,
11321131
) -> List[Union[None, str]]:
11331132
try:
@@ -1162,9 +1161,7 @@ def _validate_ids(
11621161
return new_ids
11631162

11641163
def _resolve_arg_value_types(
1165-
self,
1166-
argnames: typing.Sequence[str],
1167-
indirect: Union[bool, typing.Sequence[str]],
1164+
self, argnames: Sequence[str], indirect: Union[bool, Sequence[str]],
11681165
) -> Dict[str, "Literal['params', 'funcargs']"]:
11691166
"""Resolve if each parametrized argument must be considered a
11701167
parameter to a fixture or a "funcarg" to the function, based on the
@@ -1202,9 +1199,7 @@ def _resolve_arg_value_types(
12021199
return valtypes
12031200

12041201
def _validate_if_using_arg_names(
1205-
self,
1206-
argnames: typing.Sequence[str],
1207-
indirect: Union[bool, typing.Sequence[str]],
1202+
self, argnames: Sequence[str], indirect: Union[bool, Sequence[str]],
12081203
) -> None:
12091204
"""Check if all argnames are being used, by default values, or directly/indirectly.
12101205
@@ -1235,9 +1230,9 @@ def _validate_if_using_arg_names(
12351230

12361231

12371232
def _find_parametrized_scope(
1238-
argnames: typing.Sequence[str],
1239-
arg2fixturedefs: Mapping[str, typing.Sequence[fixtures.FixtureDef[object]]],
1240-
indirect: Union[bool, typing.Sequence[str]],
1233+
argnames: Sequence[str],
1234+
arg2fixturedefs: Mapping[str, Sequence[fixtures.FixtureDef[object]]],
1235+
indirect: Union[bool, Sequence[str]],
12411236
) -> "fixtures._Scope":
12421237
"""Find the most appropriate scope for a parametrized call based on its arguments.
12431238

0 commit comments

Comments
 (0)