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

Support "allow_none=True" in docval for args with non-None default #757

Merged
merged 2 commits into from
Aug 23, 2022

Conversation

rly
Copy link
Contributor

@rly rly commented Aug 23, 2022

Motivation

Addressing issue raised in NeurodataWithoutBorders/pynwb#1540 (comment)

How to test the behavior?

@docval({'name': 'arg1', 'type': bool, 'doc': 'this is a bool or None with a default', 'default': True,
                 'allow_none': True})
    def method(self, **kwargs):
        return popargs('arg1', kwargs)

    # if provided, None is allowed
    res = method(self, arg1=None)
    self.assertIsNone(res)

    # if not provided, the default value is used
    res = method(self)
    self.assertTrue(res)

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Have you checked our Contributing document?
  • Have you ensured the PR clearly describes the problem and the solution?
  • Is your contribution compliant with our coding style? This can be checked running flake8 from the source directory.
  • Have you checked to ensure that there aren't other open Pull Requests for the same change?
  • Have you included the relevant issue number using "Fix #XXX" notation where XXX is the issue number? By including "Fix #XXX" you allow GitHub to close issue #XXX when the PR is merged.

@codecov
Copy link

codecov bot commented Aug 23, 2022

Codecov Report

Merging #757 (7246b49) into dev (94e9e3d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##              dev     #757   +/-   ##
=======================================
  Coverage   87.59%   87.59%           
=======================================
  Files          44       44           
  Lines        8834     8837    +3     
  Branches     2034     2035    +1     
=======================================
+ Hits         7738     7741    +3     
  Misses        781      781           
  Partials      315      315           
Impacted Files Coverage Δ
src/hdmf/utils.py 96.41% <100.00%> (+0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@rly
Copy link
Contributor Author

rly commented Aug 23, 2022

Test failures are upstream in the use of conda in github actions.

@rly rly merged commit 8477ff9 into dev Aug 23, 2022
@rly rly deleted the docval_allow_none branch August 23, 2022 20:09
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.

2 participants