Skip to content

Commit

Permalink
Merge pull request #288 from cwacek/fix/286
Browse files Browse the repository at this point in the history
 bugfix: Fix an issue with #286
  • Loading branch information
cwacek authored May 20, 2024
2 parents 00fb1c8 + 02f2803 commit d41505d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 8 additions & 1 deletion python_jsonschema_objects/classbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,15 @@ def _build_literal(self, nm, clsdata):
"__propinfo__": {
"__literal__": clsdata,
"__title__": clsdata.get("title"),
# This weird value on the next line is a sentinel value, because we can't use the standard `get(
# "key", None) is not None` motif because sometimes the value is None. If someone has an actual
# value like this (which I generated by having my cat walk on my keyboard), they're out of luck.
"__default__": clsdata["default"]
if clsdata.get("default") is not None
if clsdata.get(
"default",
"asldkfn24olkjalskdfn e;laishd;1loj;flkansd;iow;naosdinfe;lkamjsdfj",
)
is not "asldkfn24olkjalskdfn e;laishd;1loj;flkansd;iow;naosdinfe;lkamjsdfj"
else clsdata.get("const"),
}
},
Expand Down
3 changes: 0 additions & 3 deletions python_jsonschema_objects/literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ def __init__(self, value, typ=None):
else:
self._value = value

if self._value is None and self.default() is not None:
self._value = self.default()

self.validate()

constval = self.const()
Expand Down

0 comments on commit d41505d

Please sign in to comment.