Merge pull request #7836 from asottile/py36_typing_X

py36+: replace typing.X with X
This commit is contained in:
Anthony Sottile 2020-10-02 19:47:42 -07:00 committed by GitHub
commit 2c7b7d8f66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 23 deletions

View File

@ -1,7 +1,7 @@
"""Generic mechanism for marking and selecting python functions.""" """Generic mechanism for marking and selecting python functions."""
import typing
import warnings import warnings
from typing import AbstractSet from typing import AbstractSet
from typing import Collection
from typing import List from typing import List
from typing import Optional from typing import Optional
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
@ -46,7 +46,7 @@ old_mark_config_key = StoreKey[Optional[Config]]()
def param( def param(
*values: object, *values: object,
marks: "Union[MarkDecorator, typing.Collection[Union[MarkDecorator, Mark]]]" = (), marks: Union[MarkDecorator, Collection[Union[MarkDecorator, Mark]]] = (),
id: Optional[str] = None id: Optional[str] = None
) -> ParameterSet: ) -> ParameterSet:
"""Specify a parameter in `pytest.mark.parametrize`_ calls or """Specify a parameter in `pytest.mark.parametrize`_ calls or

View File

@ -1,9 +1,9 @@
import collections.abc import collections.abc
import inspect import inspect
import typing
import warnings import warnings
from typing import Any from typing import Any
from typing import Callable from typing import Callable
from typing import Collection
from typing import Iterable from typing import Iterable
from typing import Iterator from typing import Iterator
from typing import List from typing import List
@ -79,7 +79,7 @@ class ParameterSet(
"ParameterSet", "ParameterSet",
[ [
("values", Sequence[Union[object, NotSetType]]), ("values", Sequence[Union[object, NotSetType]]),
("marks", "typing.Collection[Union[MarkDecorator, Mark]]"), ("marks", Collection[Union["MarkDecorator", "Mark"]]),
("id", Optional[str]), ("id", Optional[str]),
], ],
) )
@ -88,7 +88,7 @@ class ParameterSet(
def param( def param(
cls, cls,
*values: object, *values: object,
marks: "Union[MarkDecorator, typing.Collection[Union[MarkDecorator, Mark]]]" = (), marks: Union["MarkDecorator", Collection[Union["MarkDecorator", "Mark"]]] = (),
id: Optional[str] = None id: Optional[str] = None
) -> "ParameterSet": ) -> "ParameterSet":
if isinstance(marks, MarkDecorator): if isinstance(marks, MarkDecorator):

View File

@ -6,11 +6,9 @@ import itertools
import os import os
import sys import sys
import types import types
import typing
import warnings import warnings
from collections import Counter from collections import Counter
from collections import defaultdict from collections import defaultdict
from collections.abc import Sequence
from functools import partial from functools import partial
from typing import Any from typing import Any
from typing import Callable from typing import Callable
@ -21,6 +19,7 @@ from typing import Iterator
from typing import List from typing import List
from typing import Mapping from typing import Mapping
from typing import Optional from typing import Optional
from typing import Sequence
from typing import Set from typing import Set
from typing import Tuple from typing import Tuple
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
@ -668,7 +667,7 @@ class Package(Module):
def _collectfile( def _collectfile(
self, path: py.path.local, handle_dupes: bool = True self, path: py.path.local, handle_dupes: bool = True
) -> typing.Sequence[nodes.Collector]: ) -> Sequence[nodes.Collector]:
assert ( assert (
path.isfile() path.isfile()
), "{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})".format( ), "{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})".format(
@ -904,7 +903,7 @@ class CallSpec2:
def setmulti2( def setmulti2(
self, self,
valtypes: Mapping[str, "Literal['params', 'funcargs']"], valtypes: Mapping[str, "Literal['params', 'funcargs']"],
argnames: typing.Sequence[str], argnames: Sequence[str],
valset: Iterable[object], valset: Iterable[object],
id: str, id: str,
marks: Iterable[Union[Mark, MarkDecorator]], marks: Iterable[Union[Mark, MarkDecorator]],
@ -966,8 +965,8 @@ class Metafunc:
def parametrize( def parametrize(
self, self,
argnames: Union[str, List[str], Tuple[str, ...]], argnames: Union[str, List[str], Tuple[str, ...]],
argvalues: Iterable[Union[ParameterSet, typing.Sequence[object], object]], argvalues: Iterable[Union[ParameterSet, Sequence[object], object]],
indirect: Union[bool, typing.Sequence[str]] = False, indirect: Union[bool, Sequence[str]] = False,
ids: Optional[ ids: Optional[
Union[ Union[
Iterable[Union[None, str, float, int, bool]], Iterable[Union[None, str, float, int, bool]],
@ -1093,14 +1092,14 @@ class Metafunc:
def _resolve_arg_ids( def _resolve_arg_ids(
self, self,
argnames: typing.Sequence[str], argnames: Sequence[str],
ids: Optional[ ids: Optional[
Union[ Union[
Iterable[Union[None, str, float, int, bool]], Iterable[Union[None, str, float, int, bool]],
Callable[[Any], Optional[object]], Callable[[Any], Optional[object]],
] ]
], ],
parameters: typing.Sequence[ParameterSet], parameters: Sequence[ParameterSet],
nodeid: str, nodeid: str,
) -> List[str]: ) -> List[str]:
"""Resolve the actual ids for the given argnames, based on the ``ids`` parameter given """Resolve the actual ids for the given argnames, based on the ``ids`` parameter given
@ -1127,7 +1126,7 @@ class Metafunc:
def _validate_ids( def _validate_ids(
self, self,
ids: Iterable[Union[None, str, float, int, bool]], ids: Iterable[Union[None, str, float, int, bool]],
parameters: typing.Sequence[ParameterSet], parameters: Sequence[ParameterSet],
func_name: str, func_name: str,
) -> List[Union[None, str]]: ) -> List[Union[None, str]]:
try: try:
@ -1162,9 +1161,7 @@ class Metafunc:
return new_ids return new_ids
def _resolve_arg_value_types( def _resolve_arg_value_types(
self, self, argnames: Sequence[str], indirect: Union[bool, Sequence[str]],
argnames: typing.Sequence[str],
indirect: Union[bool, typing.Sequence[str]],
) -> Dict[str, "Literal['params', 'funcargs']"]: ) -> Dict[str, "Literal['params', 'funcargs']"]:
"""Resolve if each parametrized argument must be considered a """Resolve if each parametrized argument must be considered a
parameter to a fixture or a "funcarg" to the function, based on the parameter to a fixture or a "funcarg" to the function, based on the
@ -1202,9 +1199,7 @@ class Metafunc:
return valtypes return valtypes
def _validate_if_using_arg_names( def _validate_if_using_arg_names(
self, self, argnames: Sequence[str], indirect: Union[bool, Sequence[str]],
argnames: typing.Sequence[str],
indirect: Union[bool, typing.Sequence[str]],
) -> None: ) -> None:
"""Check if all argnames are being used, by default values, or directly/indirectly. """Check if all argnames are being used, by default values, or directly/indirectly.
@ -1235,9 +1230,9 @@ class Metafunc:
def _find_parametrized_scope( def _find_parametrized_scope(
argnames: typing.Sequence[str], argnames: Sequence[str],
arg2fixturedefs: Mapping[str, typing.Sequence[fixtures.FixtureDef[object]]], arg2fixturedefs: Mapping[str, Sequence[fixtures.FixtureDef[object]]],
indirect: Union[bool, typing.Sequence[str]], indirect: Union[bool, Sequence[str]],
) -> "fixtures._Scope": ) -> "fixtures._Scope":
"""Find the most appropriate scope for a parametrized call based on its arguments. """Find the most appropriate scope for a parametrized call based on its arguments.