Merge pull request #7496 from bluetech/typing-idfn
Fix typing of params ids callable form
This commit is contained in:
commit
41c40efe80
|
@ -976,7 +976,7 @@ class FixtureDef(Generic[_FixtureValue]):
|
||||||
ids: Optional[
|
ids: Optional[
|
||||||
Union[
|
Union[
|
||||||
Tuple[Union[None, str, float, int, bool], ...],
|
Tuple[Union[None, str, float, int, bool], ...],
|
||||||
Callable[[object], Optional[object]],
|
Callable[[Any], Optional[object]],
|
||||||
]
|
]
|
||||||
] = None,
|
] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -1128,13 +1128,13 @@ def _ensure_immutable_ids(
|
||||||
ids: Optional[
|
ids: Optional[
|
||||||
Union[
|
Union[
|
||||||
Iterable[Union[None, str, float, int, bool]],
|
Iterable[Union[None, str, float, int, bool]],
|
||||||
Callable[[object], Optional[object]],
|
Callable[[Any], Optional[object]],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
) -> Optional[
|
) -> Optional[
|
||||||
Union[
|
Union[
|
||||||
Tuple[Union[None, str, float, int, bool], ...],
|
Tuple[Union[None, str, float, int, bool], ...],
|
||||||
Callable[[object], Optional[object]],
|
Callable[[Any], Optional[object]],
|
||||||
]
|
]
|
||||||
]:
|
]:
|
||||||
if ids is None:
|
if ids is None:
|
||||||
|
@ -1180,7 +1180,7 @@ class FixtureFunctionMarker:
|
||||||
ids = attr.ib(
|
ids = attr.ib(
|
||||||
type=Union[
|
type=Union[
|
||||||
Tuple[Union[None, str, float, int, bool], ...],
|
Tuple[Union[None, str, float, int, bool], ...],
|
||||||
Callable[[object], Optional[object]],
|
Callable[[Any], Optional[object]],
|
||||||
],
|
],
|
||||||
default=None,
|
default=None,
|
||||||
converter=_ensure_immutable_ids,
|
converter=_ensure_immutable_ids,
|
||||||
|
@ -1223,7 +1223,7 @@ def fixture(
|
||||||
ids: Optional[
|
ids: Optional[
|
||||||
Union[
|
Union[
|
||||||
Iterable[Union[None, str, float, int, bool]],
|
Iterable[Union[None, str, float, int, bool]],
|
||||||
Callable[[object], Optional[object]],
|
Callable[[Any], Optional[object]],
|
||||||
]
|
]
|
||||||
] = ...,
|
] = ...,
|
||||||
name: Optional[str] = ...
|
name: Optional[str] = ...
|
||||||
|
@ -1241,7 +1241,7 @@ def fixture( # noqa: F811
|
||||||
ids: Optional[
|
ids: Optional[
|
||||||
Union[
|
Union[
|
||||||
Iterable[Union[None, str, float, int, bool]],
|
Iterable[Union[None, str, float, int, bool]],
|
||||||
Callable[[object], Optional[object]],
|
Callable[[Any], Optional[object]],
|
||||||
]
|
]
|
||||||
] = ...,
|
] = ...,
|
||||||
name: Optional[str] = None
|
name: Optional[str] = None
|
||||||
|
@ -1258,7 +1258,7 @@ def fixture( # noqa: F811
|
||||||
ids: Optional[
|
ids: Optional[
|
||||||
Union[
|
Union[
|
||||||
Iterable[Union[None, str, float, int, bool]],
|
Iterable[Union[None, str, float, int, bool]],
|
||||||
Callable[[object], Optional[object]],
|
Callable[[Any], Optional[object]],
|
||||||
]
|
]
|
||||||
] = None,
|
] = None,
|
||||||
name: Optional[str] = None
|
name: Optional[str] = None
|
||||||
|
|
|
@ -433,7 +433,7 @@ if TYPE_CHECKING:
|
||||||
ids: Optional[
|
ids: Optional[
|
||||||
Union[
|
Union[
|
||||||
Iterable[Union[None, str, float, int, bool]],
|
Iterable[Union[None, str, float, int, bool]],
|
||||||
Callable[[object], Optional[object]],
|
Callable[[Any], Optional[object]],
|
||||||
]
|
]
|
||||||
] = ...,
|
] = ...,
|
||||||
scope: Optional[_Scope] = ...
|
scope: Optional[_Scope] = ...
|
||||||
|
|
|
@ -11,6 +11,7 @@ from collections import Counter
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from typing import Any
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
|
@ -920,7 +921,7 @@ class Metafunc:
|
||||||
ids: Optional[
|
ids: Optional[
|
||||||
Union[
|
Union[
|
||||||
Iterable[Union[None, str, float, int, bool]],
|
Iterable[Union[None, str, float, int, bool]],
|
||||||
Callable[[object], Optional[object]],
|
Callable[[Any], Optional[object]],
|
||||||
]
|
]
|
||||||
] = None,
|
] = None,
|
||||||
scope: "Optional[_Scope]" = None,
|
scope: "Optional[_Scope]" = None,
|
||||||
|
@ -1040,7 +1041,7 @@ class Metafunc:
|
||||||
ids: Optional[
|
ids: Optional[
|
||||||
Union[
|
Union[
|
||||||
Iterable[Union[None, str, float, int, bool]],
|
Iterable[Union[None, str, float, int, bool]],
|
||||||
Callable[[object], Optional[object]],
|
Callable[[Any], Optional[object]],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
parameters: typing.Sequence[ParameterSet],
|
parameters: typing.Sequence[ParameterSet],
|
||||||
|
@ -1226,7 +1227,7 @@ def _idval(
|
||||||
val: object,
|
val: object,
|
||||||
argname: str,
|
argname: str,
|
||||||
idx: int,
|
idx: int,
|
||||||
idfn: Optional[Callable[[object], Optional[object]]],
|
idfn: Optional[Callable[[Any], Optional[object]]],
|
||||||
nodeid: Optional[str],
|
nodeid: Optional[str],
|
||||||
config: Optional[Config],
|
config: Optional[Config],
|
||||||
) -> str:
|
) -> str:
|
||||||
|
@ -1266,7 +1267,7 @@ def _idvalset(
|
||||||
idx: int,
|
idx: int,
|
||||||
parameterset: ParameterSet,
|
parameterset: ParameterSet,
|
||||||
argnames: Iterable[str],
|
argnames: Iterable[str],
|
||||||
idfn: Optional[Callable[[object], Optional[object]]],
|
idfn: Optional[Callable[[Any], Optional[object]]],
|
||||||
ids: Optional[List[Union[None, str]]],
|
ids: Optional[List[Union[None, str]]],
|
||||||
nodeid: Optional[str],
|
nodeid: Optional[str],
|
||||||
config: Optional[Config],
|
config: Optional[Config],
|
||||||
|
@ -1287,7 +1288,7 @@ def _idvalset(
|
||||||
def idmaker(
|
def idmaker(
|
||||||
argnames: Iterable[str],
|
argnames: Iterable[str],
|
||||||
parametersets: Iterable[ParameterSet],
|
parametersets: Iterable[ParameterSet],
|
||||||
idfn: Optional[Callable[[object], Optional[object]]] = None,
|
idfn: Optional[Callable[[Any], Optional[object]]] = None,
|
||||||
ids: Optional[List[Union[None, str]]] = None,
|
ids: Optional[List[Union[None, str]]] = None,
|
||||||
config: Optional[Config] = None,
|
config: Optional[Config] = None,
|
||||||
nodeid: Optional[str] = None,
|
nodeid: Optional[str] = None,
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
"""File for checking typing issues.
|
||||||
|
|
||||||
|
This file is not executed, it is only checked by mypy to ensure that
|
||||||
|
none of the code triggers any mypy errors.
|
||||||
|
"""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
# Issue #7488.
|
||||||
|
@pytest.mark.xfail(raises=RuntimeError)
|
||||||
|
def check_mark_xfail_raises() -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Issue #7494.
|
||||||
|
@pytest.fixture(params=[(0, 0), (1, 1)], ids=lambda x: str(x[0]))
|
||||||
|
def check_fixture_ids_callable() -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Issue #7494.
|
||||||
|
@pytest.mark.parametrize("func", [str, int], ids=lambda x: str(x.__name__))
|
||||||
|
def check_parametrize_ids_callable(func) -> None:
|
||||||
|
pass
|
Loading…
Reference in New Issue