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

Make allow_none functional in the Date trait type #1432

Merged
merged 12 commits into from
Feb 9, 2021

Conversation

mdickinson
Copy link
Member

This PR makes it possible to prevent assignment of None to a Date trait. (As usual, it doesn't prevent a default value of None.)

Note that before the recently-merged PR #1429, Date was an instance of BaseInstance, and so in theory should already have allowed and respected allow_none. But a different bug (#495) means that allow_none was not respected. So this PR actually introduces a change in behaviour (effectively a bugfix) for anyone already doing: foo = Date(allow_none=False): before this PR, assignment of None would still have been permitted for such a trait declaration. After this PR, it won't be.

In detail, we:

  • Add a new parameter allow_none to Date, defaulting to True for backwards compatibility reasons
  • Prevent assignment of None if allow_none is False
  • Add some unit tests.

Checklist

  • Tests
  • [ ] Update API reference (docs/source/traits_api_reference) N/A
  • [ ] Update User manual (docs/source/traits_user_manual) N/A
  • Update type annotation hints in traits-stubs

Copy link
Contributor

@rahulporuri rahulporuri left a comment

Choose a reason for hiding this comment

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

LGTM

@mdickinson mdickinson merged commit 55f4b12 into master Feb 9, 2021
Enthought OSS Q1 2021 automation moved this from In progress to Done Feb 9, 2021
@mdickinson mdickinson deleted the feature/date-allow-none2 branch February 9, 2021 12:01
@rahulporuri rahulporuri moved this from Done to Sprint 2 : Jan 25 2021 - Feb 5 2021 in Enthought OSS Q1 2021 Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Enthought OSS Q1 2021
Sprint 2 : Jan 25 2021 - Feb 5 2021
Development

Successfully merging this pull request may close these issues.

None yet

2 participants