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

Issue with functions are default arguments #143

Open
tjhunter opened this issue Sep 2, 2021 · 0 comments
Open

Issue with functions are default arguments #143

tjhunter opened this issue Sep 2, 2021 · 0 comments

Comments

@tjhunter
Copy link
Owner

tjhunter commented Sep 2, 2021

The following code:

import dds

def f(): return 1

def g(arg = f):
    return arg()

dds.eval(g2)

causes an analyzer error:

dds.structures.DDSException: The type <class 'function'> is currently not supported. The only supported types are 'well-known' types that are part of the standard data structures in the python library. If you think your data type should be supported by DDS, please open a request ticket. General Python classes will not be supported since they can carry arbitrary state and cannot be easily compared. Consider using a dataclass, a dictionary or a named tuple instead.

The current workaround is to not have a function as a default argument:

def g2(arg = None):
    arg = arg or f
    return arg()

dds.eval(g2)
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