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

Allow lambdas for InputPort default values #133

Merged
merged 1 commit into from
Oct 25, 2019
Merged

Conversation

sphuber
Copy link
Collaborator

@sphuber sphuber commented Oct 24, 2019

Fixes #132

During the creation of the InputPort the optional default value will
now be checked if it is a callable and if so evaluated first, before
validating the returned value. In PortNamespace.pre_process the same
check needs to be performed when the default value of a port needs to be
used, evaluating it first if the default is a callable. Note that this
is only done for defaults and not for port values themselves, even if
callables are a valid type. If one passes a callable as a value for a
port that accepts them, the user expects to get the callable back after
validation and not the evaluated value.

@sphuber sphuber requested a review from muhrin October 24, 2019 17:43
During the creation of the `InputPort` the optional default value will
now be checked if it is a callable and if so evaluated first, before
validating the returned value. In `PortNamespace.pre_process` the same
check needs to be performed when the default value of a port needs to be
used, evaluating it first if the default is a callable. Note that this
is only done for defaults and not for port values themselves, even if
callables are a valid type. If one passes a callable as a value for a
port that accepts them, the user expects to get the callable back after
validation and not the evaluated value.
Copy link
Collaborator

@muhrin muhrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed on skype, good to go

@sphuber sphuber merged commit 1fb7bd0 into develop Oct 25, 2019
@sphuber sphuber deleted the fix_132_lambda_defaults branch October 25, 2019 10:05
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

Successfully merging this pull request may close these issues.

Allow lambdas for Port defaults
2 participants