~cjwatson/storm/clarify-no-allow-none-default-none-exception

Viewing all changes in revision 576.

  • Committer: Colin Watson
  • Date: 2022-03-16 16:59:21 UTC
  • Revision ID: cjwatson@canonical.com-20220316165921-8g0y1bnpe3qx0w70
Clarify exception for a property with allow_none=False and default=None.

Creating a property with `allow_none=False, default=None` doesn't make
sense, but it's sometimes easy to set things up that way by accident
during refactoring.  Storm immediately raises `NoneError` when creating
the variable in that case.  However, it's not obvious that the exception
is due to the bad default, and I spent some time with a colleague today
debugging a situation that turned out to be due to this.

Change the exception message from "None isn't acceptable as a value" to
"None isn't acceptable as a default value" in this case, to clue future
travellers into the fact that the problem relates to the default.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: