You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pytest -vvv
==================================== test session starts ====================================
platform linux -- Python 3.10.1, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /home/karthikeyan/stuff/python/myenv/bin/python
cachedir: .pytest_cache
rootdir: /tmp/testdir1
plugins: forked-1.4.0, typeguard-2.13.3, anyio-3.5.0, mypy-plugins-1.9.3, xdist-2.5.0
collected 2 items
tests/test_foo.py::test_foo[123] PASSED [ 50%]
tests/test_foo.py::test_foo[456.789] FAILED [100%]
========================================= FAILURES ==========================================
_____________________________________ test_foo[456.789] _____________________________________
args = (), kwargs = {'arg': 456.789}, memo = <typeguard._CallMemo object at 0x7fd9fc7d2620>
def wrapper(*args, **kwargs):
memo = _CallMemo(python_func, _localns, args=args, kwargs=kwargs)
> check_argument_types(memo)
/home/karthikeyan/stuff/python/myenv/lib/python3.10/site-packages/typeguard/__init__.py:1032:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
memo = <typeguard._CallMemo object at 0x7fd9fc7d2620>
def check_argument_types(memo: Optional[_CallMemo] = None) -> bool:
"""
Check that the argument values match the annotated types.
Unless both ``args`` and ``kwargs`` are provided, the information will be retrieved from
the previous stack frame (ie. from the function that called this).
:return: ``True``
:raises TypeError: if there is an argument type mismatch
"""
if memo is None:
# faster than inspect.currentframe(), but not officially
# supported in all python implementations
frame = sys._getframe(1)
try:
func = find_function(frame)
except LookupError:
return True # This can happen with the Pydev/PyCharm debugger extension installed
memo = _CallMemo(func, frame.f_locals)
for argname, expected_type in memo.type_hints.items():
if argname != 'return' and argname in memo.arguments:
value = memo.arguments[argname]
description = 'argument "{}"'.format(argname)
try:
check_type(description, value, expected_type, memo)
except TypeError as exc: # suppress unnecessarily long tracebacks
> raise TypeError(*exc.args) from None
E TypeError: type of argument "arg" must be int; got float instead
/home/karthikeyan/stuff/python/myenv/lib/python3.10/site-packages/typeguard/__init__.py:875: TypeError
================================== short test summary info ==================================
FAILED tests/test_foo.py::test_foo[456.789] - TypeError: type of argument "arg" must be in...
================================ 1 failed, 1 passed in 0.14s ================================
This one seems to not be so activate anymore, but would something like this be good practice when working with type checkers for this?
For the following above i do get incompatible types error from mypy:
Either way i have not tested the plugin but that probably works too -- also maybe this should be explained in the typing docs perhaps?
Since this can technically have "silent" errors like i showed above for certain codebases if not careful enough...
hard reject - at first glance this looks like a quickly agent strung name squat
we are not going to take ownership of something that looks prompt-dropped - whats wrong with people - we barely have time to react to all of the agent based bombard
Activity
[-]mypy plugin for @mark.parametrizev[/-][+]mypy plugin for @mark.parametrize[/+][-]mypy plugin for @mark.parametrize[/-][+]mypy plugin for `@mark.parametrize`[/+]The-Compiler commentedon Nov 24, 2021
That seems like a good idea - but I don't think it should be part of pytest core.
tirkarthi commentedon Jan 15, 2022
Nice idea. I found that there is typeguard project which can be used to perform run-time type checks.
adamtheturtle commentedon Aug 21, 2024
I think that the
mypyplugin couldn't work for indirect parametrisation, e.g. from the documentation:This is where typeguard can help.
phalberg commentedon Oct 4, 2026
This one seems to not be so activate anymore, but would something like this be good practice when working with type checkers for this?
For the following above i do get incompatible types error from mypy:
But no errors when i run something like the following below:
Either way i have not tested the plugin but that probably works too -- also maybe this should be explained in the
typingdocs perhaps?Since this can technically have "silent" errors like i showed above for certain codebases if not careful enough...
Any thoughts?
adamtheturtle commentedon Oct 5, 2026
pytest-beartypeis a good runtime option for this problem.adamtheturtle commentedon Oct 5, 2026
I have published mypy-pytest-parametrize with support for this (not indirect parametrisation).
I'm happy to transfer ownership if
pytest-devfolks want to own it.RonnyPfannschmidt commentedon Oct 5, 2026
hard reject - at first glance this looks like a quickly agent strung name squat
we are not going to take ownership of something that looks prompt-dropped - whats wrong with people - we barely have time to react to all of the agent based bombard