Skip to content

Commit

Permalink
Fixed type hint errors detected by pyright. Fixed #270
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain MARIE committed May 7, 2022
1 parent def94ce commit 83c7f6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 83c7f6b

Please sign in to comment.