Skip to content

Commit

Permalink
Merge pull request #7836 from asottile/py36_typing_X
Browse files Browse the repository at this point in the history
py36+: replace typing.X with X
  • Loading branch information
asottile committed Oct 3, 2020
2 parents ac18988 + cf220b9 commit 2c7b7d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/_pytest/mark/__init__.py
@@ -1,7 +1,7 @@
"""Generic mechanism for marking and selecting python functions."""
import typing
import warnings
from typing import AbstractSet
from typing import Collection
from typing import List
from typing import Optional
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -46,7 +46,7 @@

def param(
*values: object,
marks: "Union[MarkDecorator, typing.Collection[Union[MarkDecorator, Mark]]]" = (),
marks: Union[MarkDecorator, Collection[Union[MarkDecorator, Mark]]] = (),
id: Optional[str] = None
) -> ParameterSet:
"""Specify a parameter in `pytest.mark.parametrize`_ calls or
Expand Down
6 changes: 3 additions & 3 deletions src/_pytest/mark/structures.py
@@ -1,9 +1,9 @@
import collections.abc
import inspect
import typing
import warnings
from typing import Any
from typing import Callable
from typing import Collection
from typing import Iterable
from typing import Iterator
from typing import List
Expand Down Expand Up @@ -79,7 +79,7 @@ class ParameterSet(
"ParameterSet",
[
("values", Sequence[Union[object, NotSetType]]),
("marks", "typing.Collection[Union[MarkDecorator, Mark]]"),
("marks", Collection[Union["MarkDecorator", "Mark"]]),
("id", Optional[str]),
],
)
Expand All @@ -88,7 +88,7 @@ class ParameterSet(
def param(
cls,
*values: object,
marks: "Union[MarkDecorator, typing.Collection[Union[MarkDecorator, Mark]]]" = (),
marks: Union["MarkDecorator", Collection[Union["MarkDecorator", "Mark"]]] = (),
id: Optional[str] = None
) -> "ParameterSet":
if isinstance(marks, MarkDecorator):
Expand Down
31 changes: 13 additions & 18 deletions src/_pytest/python.py
Expand Up @@ -6,11 +6,9 @@
import os
import sys
import types
import typing
import warnings
from collections import Counter
from collections import defaultdict
from collections.abc import Sequence
from functools import partial
from typing import Any
from typing import Callable
Expand All @@ -21,6 +19,7 @@
from typing import List
from typing import Mapping
from typing import Optional
from typing import Sequence
from typing import Set
from typing import Tuple
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -668,7 +667,7 @@ def _recurse(self, direntry: "os.DirEntry[str]") -> bool:

def _collectfile(
self, path: py.path.local, handle_dupes: bool = True
) -> typing.Sequence[nodes.Collector]:
) -> Sequence[nodes.Collector]:
assert (
path.isfile()
), "{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})".format(
Expand Down Expand Up @@ -904,7 +903,7 @@ def id(self) -> str:
def setmulti2(
self,
valtypes: Mapping[str, "Literal['params', 'funcargs']"],
argnames: typing.Sequence[str],
argnames: Sequence[str],
valset: Iterable[object],
id: str,
marks: Iterable[Union[Mark, MarkDecorator]],
Expand Down Expand Up @@ -966,8 +965,8 @@ def __init__(
def parametrize(
self,
argnames: Union[str, List[str], Tuple[str, ...]],
argvalues: Iterable[Union[ParameterSet, typing.Sequence[object], object]],
indirect: Union[bool, typing.Sequence[str]] = False,
argvalues: Iterable[Union[ParameterSet, Sequence[object], object]],
indirect: Union[bool, Sequence[str]] = False,
ids: Optional[
Union[
Iterable[Union[None, str, float, int, bool]],
Expand Down Expand Up @@ -1093,14 +1092,14 @@ def parametrize(

def _resolve_arg_ids(
self,
argnames: typing.Sequence[str],
argnames: Sequence[str],
ids: Optional[
Union[
Iterable[Union[None, str, float, int, bool]],
Callable[[Any], Optional[object]],
]
],
parameters: typing.Sequence[ParameterSet],
parameters: Sequence[ParameterSet],
nodeid: str,
) -> List[str]:
"""Resolve the actual ids for the given argnames, based on the ``ids`` parameter given
Expand All @@ -1127,7 +1126,7 @@ def _resolve_arg_ids(
def _validate_ids(
self,
ids: Iterable[Union[None, str, float, int, bool]],
parameters: typing.Sequence[ParameterSet],
parameters: Sequence[ParameterSet],
func_name: str,
) -> List[Union[None, str]]:
try:
Expand Down Expand Up @@ -1162,9 +1161,7 @@ def _validate_ids(
return new_ids

def _resolve_arg_value_types(
self,
argnames: typing.Sequence[str],
indirect: Union[bool, typing.Sequence[str]],
self, argnames: Sequence[str], indirect: Union[bool, Sequence[str]],
) -> Dict[str, "Literal['params', 'funcargs']"]:
"""Resolve if each parametrized argument must be considered a
parameter to a fixture or a "funcarg" to the function, based on the
Expand Down Expand Up @@ -1202,9 +1199,7 @@ def _resolve_arg_value_types(
return valtypes

def _validate_if_using_arg_names(
self,
argnames: typing.Sequence[str],
indirect: Union[bool, typing.Sequence[str]],
self, argnames: Sequence[str], indirect: Union[bool, Sequence[str]],
) -> None:
"""Check if all argnames are being used, by default values, or directly/indirectly.
Expand Down Expand Up @@ -1235,9 +1230,9 @@ def _validate_if_using_arg_names(


def _find_parametrized_scope(
argnames: typing.Sequence[str],
arg2fixturedefs: Mapping[str, typing.Sequence[fixtures.FixtureDef[object]]],
indirect: Union[bool, typing.Sequence[str]],
argnames: Sequence[str],
arg2fixturedefs: Mapping[str, Sequence[fixtures.FixtureDef[object]]],
indirect: Union[bool, Sequence[str]],
) -> "fixtures._Scope":
"""Find the most appropriate scope for a parametrized call based on its arguments.
Expand Down

0 comments on commit 2c7b7d8

Please sign in to comment.