pytypes icon indicating copy to clipboard operation
pytypes copied to clipboard

@typechecked fails to correctly parse functions with PEP 3102

Open sg-s opened this issue 2 years ago • 0 comments

example:


from pytypes import typechecked

@typechecked
def foo(a: int, *, c: str):
    for _ in range(a):
        print(c)

foo(10,c="1")

leads to this:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [17], in <cell line: 1>()
----> 1 foo(10,"1")

File ~/opt/anaconda3/envs/isxcore_github/lib/python3.8/site-packages/pytypes/typechecker.py:882, in _typeinspect_func.<locals>.checker_tp(*args, **kw)
    880         res = func(args[0], *checked_args, **checked_kw)
    881     else:
--> 882         res = func(*checked_args, **checked_kw)
    884 checked_res = _checkfuncresult(resSig, res, toCheck, \
    885         slf or clsm, parent_class, True, prop_getter, bound_typevars=bound_typevars)
    886 if pytypes.do_logging_in_typechecked:

TypeError: foo() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given

sg-s avatar Apr 06 '22 18:04 sg-s