Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions driver/normalizer/tonode.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ var ToNode = &uast.ObjectToNode{
"Div": "/",
"Ellipsis": "...",
"Eq": "==",
"False": "false",
"For": "for",
"FloorDiv": "//",
"Global": "global",
Expand All @@ -53,7 +52,6 @@ var ToNode = &uast.ObjectToNode{
"LtE": "<=",
"Mod": "%%",
"Mult": "*",
"None": "None",
"Nonlocal": "nonlocal",
"Not": "!",
"NotEq": "!=",
Expand All @@ -65,7 +63,6 @@ var ToNode = &uast.ObjectToNode{
"Return": "return",
"RShift": ">>",
"Sub": "-",
"True": "true",
"UAdd": "+",
"USub": "-",
"While": "while",
Expand Down
6 changes: 3 additions & 3 deletions fixtures/assert_constant.py.native
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lineno": 1,
"msg": null,
"test": {
"LiteralValue": true,
"LiteralValue": "True",
"ast_type": "BoolLiteral",
"col_offset": 8,
"end_col_offset": 11,
Expand All @@ -30,7 +30,7 @@
"lineno": 2,
"msg": null,
"test": {
"LiteralValue": true,
"LiteralValue": "True",
"ast_type": "BoolLiteral",
"col_offset": 8,
"end_col_offset": 11,
Expand All @@ -54,7 +54,7 @@
"s": "assert message"
},
"test": {
"LiteralValue": true,
"LiteralValue": "True",
"ast_type": "BoolLiteral",
"col_offset": 8,
"end_col_offset": 11,
Expand Down
6 changes: 3 additions & 3 deletions fixtures/assert_constant.py.uast
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Module {
. . . Children: {
. . . . 0: BoolLiteral {
. . . . . Roles: Literal,Boolean,Expression,Primitive
. . . . . TOKEN "true"
. . . . . TOKEN "True"
. . . . . StartPosition: {
. . . . . . Offset: 7
. . . . . . Line: 1
Expand Down Expand Up @@ -62,7 +62,7 @@ Module {
. . . Children: {
. . . . 0: BoolLiteral {
. . . . . Roles: Literal,Boolean,Expression,Primitive
. . . . . TOKEN "true"
. . . . . TOKEN "True"
. . . . . StartPosition: {
. . . . . . Offset: 20
. . . . . . Line: 2
Expand Down Expand Up @@ -116,7 +116,7 @@ Module {
. . . . }
. . . . 1: BoolLiteral {
. . . . . Roles: Literal,Boolean,Expression,Primitive
. . . . . TOKEN "true"
. . . . . TOKEN "True"
. . . . . StartPosition: {
. . . . . . Offset: 32
. . . . . . Line: 3
Expand Down
2 changes: 1 addition & 1 deletion fixtures/functiondef_defaultparams.py.native
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"s": "polompos"
},
{
"LiteralValue": null,
"LiteralValue": "None",
"ast_type": "NoneLiteral",
"col_offset": 56,
"end_col_offset": 59,
Expand Down
2 changes: 1 addition & 1 deletion fixtures/functiondef_defaultparams.py.uast
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Module {
. . . . . . . . }
. . . . . . . . 2: NoneLiteral {
. . . . . . . . . Roles: Literal,Null,Expression,Primitive
. . . . . . . . . TOKEN "<nil>"
. . . . . . . . . TOKEN "None"
. . . . . . . . . StartPosition: {
. . . . . . . . . . Offset: 55
. . . . . . . . . . Line: 1
Expand Down
6 changes: 3 additions & 3 deletions fixtures/if.py.native
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"value": {
"args": [
{
"LiteralValue": true,
"LiteralValue": "True",
"ast_type": "BoolLiteral",
"col_offset": 11,
"end_col_offset": 14,
Expand Down Expand Up @@ -46,7 +46,7 @@
"lineno": 1,
"orelse": [],
"test": {
"LiteralValue": true,
"LiteralValue": "True",
"ast_type": "BoolLiteral",
"col_offset": 4,
"end_col_offset": 7,
Expand All @@ -65,7 +65,7 @@
"value": {
"args": [
{
"LiteralValue": true,
"LiteralValue": "True",
"ast_type": "BoolLiteral",
"col_offset": 11,
"end_col_offset": 14,
Expand Down
6 changes: 3 additions & 3 deletions fixtures/if.py.uast
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -90,7 +90,7 @@ Module {
. . . . }
. . . . 1: BoolLiteral {
. . . . . Roles: Literal,Boolean,Expression,Primitive,If,Condition
. . . . . TOKEN "true"
. . . . . TOKEN "True"
. . . . . StartPosition: {
. . . . . . Offset: 3
. . . . . . Line: 1
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fixtures/issue58.py.native
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"n": 0
},
{
"LiteralValue": null,
"LiteralValue": "None",
"ast_type": "NoneLiteral",
"col_offset": 11,
"end_col_offset": 14,
Expand Down
2 changes: 1 addition & 1 deletion fixtures/issue58.py.uast
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Module {
. . . . . . }
. . . . . . 1: NoneLiteral {
. . . . . . . Roles: Literal,Null,Expression,Primitive
. . . . . . . TOKEN "<nil>"
. . . . . . . TOKEN "None"
. . . . . . . StartPosition: {
. . . . . . . . Offset: 10
. . . . . . . . Line: 1
Expand Down
2 changes: 1 addition & 1 deletion fixtures/literals_assign.py.native
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
}
],
"value": {
"LiteralValue": null,
"LiteralValue": "None",
"ast_type": "NoneLiteral",
"col_offset": 5,
"end_col_offset": 8,
Expand Down
2 changes: 1 addition & 1 deletion fixtures/literals_assign.py.uast
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Module {
. . . . }
. . . . 1: NoneLiteral {
. . . . . Roles: Literal,Null,Expression,Primitive,Right
. . . . . TOKEN "<nil>"
. . . . . TOKEN "None"
. . . . . StartPosition: {
. . . . . . Offset: 59
. . . . . . Line: 4
Expand Down
10 changes: 5 additions & 5 deletions native/python_package/python_driver/astimprove.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down