Conversation
| :rtype: List[str] | ||
| :return: the list of ids for each argname given | ||
| """ | ||
| idfn = None |
There was a problem hiding this comment.
I rearranged the code here to make it amenable to mypy. I also think it's a bit clearer.
| func_name: str, | ||
| ) -> List[Union[None, str]]: | ||
| try: | ||
| len(ids) |
There was a problem hiding this comment.
I had to refactor a bit to make it amenable to mypy. It's meant to be equivalent.
| except TypeError: | ||
| raise TypeError("ids must be a callable, sequence or generator") | ||
| else: | ||
| import itertools |
There was a problem hiding this comment.
I moved this import up -- don't see why it should be lazy.
| ) | ||
| else: | ||
| if isinstance(indirect, (tuple, list)): | ||
| if isinstance(indirect, Sequence): |
There was a problem hiding this comment.
Generalized this a bit to make typing easier. It's also what other functions already check - was inconsistent.
| :param indirect: same ``indirect`` parameter of ``parametrize()``. | ||
| :raise ValueError: if validation fails | ||
| """ | ||
| if isinstance(indirect, bool) and indirect is True: |
There was a problem hiding this comment.
Had to rearrange things here a bit.
| elif isinstance(val, enum.Enum): | ||
| return str(val) | ||
| elif hasattr(val, "__name__") and isinstance(val.__name__, str): | ||
| elif isinstance(getattr(val, "__name__", None), str): |
There was a problem hiding this comment.
Changed a bit to avoid mypy attr warnings.
| def pytest_generate_tests(metafunc: "Metafunc") -> None: | ||
| for marker in metafunc.definition.iter_markers(name="parametrize"): | ||
| metafunc.parametrize(*marker.args, **marker.kwargs, _param_mark=marker) | ||
| # TODO: Fix this type-ignore (overlapping kwargs). |
There was a problem hiding this comment.
Do you have a plan for this?
There was a problem hiding this comment.
Not really. There's a workaround of creating kwargs = {**marker.kwargs, '_param_marker': marker} but I think it's worse than the disease.
99ce6ac to
5945c3f
Compare
|
Thanks @blueyed, I applied the changes. |
Extracted from #6717.