-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Process
: Allow None
for input ports that are not required
Python functions and process functions accept `None` for arguments that define that as a default without any issues. That is to say, the following works just fine: from aiida.engine import calcfunction @calcfunction def accepts_none(a=None): pass accepts_none() accepts_none(None) For a `Process`, however, `None` is not accepted even if the port is not required. This can be annoying for users because when writing wrappers around a process launcher, they will have to manually check for one of the inputs being `None` and remove it before submitting the input dictionary. Here we update the `InputPort` constructor to automatically add the `NoneType` to the `valid_type` argument if the port is marked as `required=False`. This way, non-required ports will accept `None` without raising an exception during input validation.
- Loading branch information
Showing
4 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters