Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed type hint errors detected by pyright. #271

Merged
merged 1 commit into from May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/changelog.md
@@ -1,5 +1,9 @@
# Changelog

### 3.6.12 - type hint fix

- Fixed type hint errors detected by `pyright`. Fixed [#270](https://github.com/smarie/python-pytest-cases/issues/270)

### 3.6.11 - bugfix for pytest-xdist and `get_all_cases` API improvement

- `get_all_cases` can now be called without `parametrization_target` (defaulting to the caller module), and with an explicit module object. Fixed [#258](https://github.com/smarie/python-pytest-cases/issues/258). PR [#260](https://github.com/smarie/python-pytest-cases/pull/260) by [@eddiebergman](https://github.com/eddiebergman).
Expand Down
8 changes: 7 additions & 1 deletion src/pytest_cases/fixture_parametrize_plus.py
Expand Up @@ -17,8 +17,10 @@
from collections import Iterable

try:
from typing import Union, Callable, List, Any, Sequence, Optional, Type, Tuple # noqa
from typing import Union, Callable, List, Any, Sequence, Optional, Type, Tuple, TypeVar # noqa
from types import ModuleType # noqa

T = TypeVar('T', bound=Union[Type, Callable])
except ImportError:
pass

Expand Down Expand Up @@ -624,6 +626,7 @@ def parametrize(argnames=None, # type: Union[str, Tuple[str], List[str]]
hook=None, # type: Callable[[Callable], Callable]
debug=False, # type: bool
**args):
# type: (...) -> Callable[[T], T]
"""
Equivalent to `@pytest.mark.parametrize` but also supports

Expand Down Expand Up @@ -733,6 +736,7 @@ def _parametrize_plus(argnames=None, # type: Union[str, Tuple[str], List[str]]
hook=None, # type: Callable[[Callable], Callable]
debug=False, # type: bool
**args):
# type: (...) -> Tuple[Callable[[T], T], bool]
"""

:return: a tuple (decorator, needs_inject) where needs_inject is True if decorator has signature (f, host)
Expand Down Expand Up @@ -790,6 +794,7 @@ def _make_ids(**args):
else:
# wrap the decorator to check if the test function has the parameters as arguments
def _apply(test_func):
# type: (...) -> Callable[[T], T]
if not safe_isclass(test_func):
# a Function: raise a proper error message if improper use
s = signature(test_func)
Expand Down Expand Up @@ -923,6 +928,7 @@ def _create_fixture_ref_product(fh, union_name, i, fixture_ref_positions, test_f

# Then create the decorator per se
def parametrize_plus_decorate(test_func, fixtures_dest):
# type: (...) -> Callable[[T], T]
"""
A decorator that wraps the test function so that instead of receiving the parameter names, it receives the
new fixture. All other decorations are unchanged.
Expand Down