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

@typechecked fails to correctly parse functions with PEP 3102 #117

Open
sg-s opened this issue Apr 6, 2022 · 0 comments
Open

@typechecked fails to correctly parse functions with PEP 3102 #117

sg-s opened this issue Apr 6, 2022 · 0 comments

Comments

@sg-s
Copy link

sg-s commented Apr 6, 2022

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant