Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 22c7fa4

Browse files
committed
Version 0.2.0.
- Change constants J2P, P2J, IJ, IP to longer names. - Fixes a bug in decorated error messages. - Make encoding enums attempt to call the constructor.
1 parent f8b8815 commit 22c7fa4

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

json_syntax/action_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from datetime import date, datetime, time
44
import math
5-
from operator import attrgetter
65

76

87
def check_parse_error(value, parser, error):
@@ -43,7 +42,8 @@ def check_float(value):
4342
)
4443

4544

46-
convert_enum_str = attrgetter("name")
45+
def convert_enum_str(value, typ):
46+
return typ(value).name
4747

4848

4949
def convert_none(value):

json_syntax/std.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def enums(verb, typ, ctx):
175175
"Rule to convert between enumerated types and strings."
176176
if issub_safe(typ, Enum):
177177
if verb == PY2JSON:
178-
return convert_enum_str
178+
return partial(convert_enum_str, typ=typ)
179179
elif verb == JSON2PY:
180180
return partial(convert_str_enum, mapping=dict(typ.__members__))
181181
elif verb == INSP_PY:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "json-syntax"
3-
version = "0.2.0-alpha.2"
3+
version = "0.2.0"
44
description = "Generates functions to convert Python classes to JSON dumpable objects."
55
authors = ["Ben Samuel <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)