diff --git a/driver/normalizer/tonode.go b/driver/normalizer/tonode.go index 449715b3..c29c156c 100644 --- a/driver/normalizer/tonode.go +++ b/driver/normalizer/tonode.go @@ -37,7 +37,6 @@ var ToNode = &uast.ObjectToNode{ "Div": "/", "Ellipsis": "...", "Eq": "==", - "False": "false", "For": "for", "FloorDiv": "//", "Global": "global", @@ -53,7 +52,6 @@ var ToNode = &uast.ObjectToNode{ "LtE": "<=", "Mod": "%%", "Mult": "*", - "None": "None", "Nonlocal": "nonlocal", "Not": "!", "NotEq": "!=", @@ -65,7 +63,6 @@ var ToNode = &uast.ObjectToNode{ "Return": "return", "RShift": ">>", "Sub": "-", - "True": "true", "UAdd": "+", "USub": "-", "While": "while", diff --git a/fixtures/assert_constant.py.native b/fixtures/assert_constant.py.native index 48eba256..8c6d757b 100644 --- a/fixtures/assert_constant.py.native +++ b/fixtures/assert_constant.py.native @@ -13,7 +13,7 @@ "lineno": 1, "msg": null, "test": { - "LiteralValue": true, + "LiteralValue": "True", "ast_type": "BoolLiteral", "col_offset": 8, "end_col_offset": 11, @@ -30,7 +30,7 @@ "lineno": 2, "msg": null, "test": { - "LiteralValue": true, + "LiteralValue": "True", "ast_type": "BoolLiteral", "col_offset": 8, "end_col_offset": 11, @@ -54,7 +54,7 @@ "s": "assert message" }, "test": { - "LiteralValue": true, + "LiteralValue": "True", "ast_type": "BoolLiteral", "col_offset": 8, "end_col_offset": 11, diff --git a/fixtures/assert_constant.py.uast b/fixtures/assert_constant.py.uast index d503bb29..892141ce 100644 --- a/fixtures/assert_constant.py.uast +++ b/fixtures/assert_constant.py.uast @@ -24,7 +24,7 @@ Module { . . . Children: { . . . . 0: BoolLiteral { . . . . . Roles: Literal,Boolean,Expression,Primitive -. . . . . TOKEN "true" +. . . . . TOKEN "True" . . . . . StartPosition: { . . . . . . Offset: 7 . . . . . . Line: 1 @@ -62,7 +62,7 @@ Module { . . . Children: { . . . . 0: BoolLiteral { . . . . . Roles: Literal,Boolean,Expression,Primitive -. . . . . TOKEN "true" +. . . . . TOKEN "True" . . . . . StartPosition: { . . . . . . Offset: 20 . . . . . . Line: 2 @@ -116,7 +116,7 @@ Module { . . . . } . . . . 1: BoolLiteral { . . . . . Roles: Literal,Boolean,Expression,Primitive -. . . . . TOKEN "true" +. . . . . TOKEN "True" . . . . . StartPosition: { . . . . . . Offset: 32 . . . . . . Line: 3 diff --git a/fixtures/functiondef_defaultparams.py.native b/fixtures/functiondef_defaultparams.py.native index ef2ca67f..678e6cbe 100644 --- a/fixtures/functiondef_defaultparams.py.native +++ b/fixtures/functiondef_defaultparams.py.native @@ -73,7 +73,7 @@ "s": "polompos" }, { - "LiteralValue": null, + "LiteralValue": "None", "ast_type": "NoneLiteral", "col_offset": 56, "end_col_offset": 59, diff --git a/fixtures/functiondef_defaultparams.py.uast b/fixtures/functiondef_defaultparams.py.uast index 992c351c..2db0209b 100644 --- a/fixtures/functiondef_defaultparams.py.uast +++ b/fixtures/functiondef_defaultparams.py.uast @@ -156,7 +156,7 @@ Module { . . . . . . . . } . . . . . . . . 2: NoneLiteral { . . . . . . . . . Roles: Literal,Null,Expression,Primitive -. . . . . . . . . TOKEN "" +. . . . . . . . . TOKEN "None" . . . . . . . . . StartPosition: { . . . . . . . . . . Offset: 55 . . . . . . . . . . Line: 1 diff --git a/fixtures/if.py.native b/fixtures/if.py.native index b258112f..e9bdb728 100644 --- a/fixtures/if.py.native +++ b/fixtures/if.py.native @@ -15,7 +15,7 @@ "value": { "args": [ { - "LiteralValue": true, + "LiteralValue": "True", "ast_type": "BoolLiteral", "col_offset": 11, "end_col_offset": 14, @@ -46,7 +46,7 @@ "lineno": 1, "orelse": [], "test": { - "LiteralValue": true, + "LiteralValue": "True", "ast_type": "BoolLiteral", "col_offset": 4, "end_col_offset": 7, @@ -65,7 +65,7 @@ "value": { "args": [ { - "LiteralValue": true, + "LiteralValue": "True", "ast_type": "BoolLiteral", "col_offset": 11, "end_col_offset": 14, diff --git a/fixtures/if.py.uast b/fixtures/if.py.uast index a468be2f..374f7074 100644 --- a/fixtures/if.py.uast +++ b/fixtures/if.py.uast @@ -48,7 +48,7 @@ Module { . . . . . . . . . Children: { . . . . . . . . . . 0: BoolLiteral { . . . . . . . . . . . Roles: Literal,Boolean,Expression,Primitive,Function,Call,Positional,Argument,Name -. . . . . . . . . . . TOKEN "true" +. . . . . . . . . . . TOKEN "True" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 19 . . . . . . . . . . . . Line: 2 @@ -90,7 +90,7 @@ Module { . . . . } . . . . 1: BoolLiteral { . . . . . Roles: Literal,Boolean,Expression,Primitive,If,Condition -. . . . . TOKEN "true" +. . . . . TOKEN "True" . . . . . StartPosition: { . . . . . . Offset: 3 . . . . . . Line: 1 @@ -152,7 +152,7 @@ Module { . . . . . . . . . Children: { . . . . . . . . . . 0: BoolLiteral { . . . . . . . . . . . Roles: Literal,Boolean,Expression,Primitive,Function,Call,Positional,Argument,Name -. . . . . . . . . . . TOKEN "true" +. . . . . . . . . . . TOKEN "True" . . . . . . . . . . . StartPosition: { . . . . . . . . . . . . Offset: 55 . . . . . . . . . . . . Line: 5 diff --git a/fixtures/issue58.py.native b/fixtures/issue58.py.native index 60a565b0..7178ff74 100644 --- a/fixtures/issue58.py.native +++ b/fixtures/issue58.py.native @@ -51,7 +51,7 @@ "n": 0 }, { - "LiteralValue": null, + "LiteralValue": "None", "ast_type": "NoneLiteral", "col_offset": 11, "end_col_offset": 14, diff --git a/fixtures/issue58.py.uast b/fixtures/issue58.py.uast index 560d5cfd..fb2c1c14 100644 --- a/fixtures/issue58.py.uast +++ b/fixtures/issue58.py.uast @@ -96,7 +96,7 @@ Module { . . . . . . } . . . . . . 1: NoneLiteral { . . . . . . . Roles: Literal,Null,Expression,Primitive -. . . . . . . TOKEN "" +. . . . . . . TOKEN "None" . . . . . . . StartPosition: { . . . . . . . . Offset: 10 . . . . . . . . Line: 1 diff --git a/fixtures/literals_assign.py.native b/fixtures/literals_assign.py.native index 352f6364..4e1309d9 100644 --- a/fixtures/literals_assign.py.native +++ b/fixtures/literals_assign.py.native @@ -125,7 +125,7 @@ } ], "value": { - "LiteralValue": null, + "LiteralValue": "None", "ast_type": "NoneLiteral", "col_offset": 5, "end_col_offset": 8, diff --git a/fixtures/literals_assign.py.uast b/fixtures/literals_assign.py.uast index 2cebd0b9..7361f6fc 100644 --- a/fixtures/literals_assign.py.uast +++ b/fixtures/literals_assign.py.uast @@ -255,7 +255,7 @@ Module { . . . . } . . . . 1: NoneLiteral { . . . . . Roles: Literal,Null,Expression,Primitive,Right -. . . . . TOKEN "" +. . . . . TOKEN "None" . . . . . StartPosition: { . . . . . . Offset: 59 . . . . . . Line: 4 diff --git a/native/python_package/python_driver/astimprove.py b/native/python_package/python_driver/astimprove.py index 21a9e69b..5d4bf70d 100644 --- a/native/python_package/python_driver/astimprove.py +++ b/native/python_package/python_driver/astimprove.py @@ -483,13 +483,13 @@ def _promote_names(self, node): return node def visit_NameConstant(self, node): - if 'value' in node: + if "value" in node: repr_val = repr(node["value"]) - if repr_val in ('True', 'False'): - node.update({"LiteralValue": node["value"], + if repr_val in ("True", "False"): + node.update({"LiteralValue": "True" if node["value"] else "False", "ast_type": "BoolLiteral"}) - elif repr_val == 'None': - node.update({"LiteralValue": node["value"], + elif repr_val == "None": + node.update({"LiteralValue": "None", "ast_type": "NoneLiteral"}) else: node["ast_type"] = "NameConstant"