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

Commit c8d83a6

Browse files
author
Juanjo Alvarez
committed
Fix Boolean nodes having lowercased token
1 parent 4b33f7e commit c8d83a6

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

driver/normalizer/tonode.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ var ToNode = &uast.ObjectToNode{
8383
"Div": "/",
8484
"Ellipsis": "...",
8585
"Eq": "==",
86-
"False": "false",
8786
"For": "for",
8887
"FloorDiv": "//",
8988
"Global": "global",
@@ -111,7 +110,6 @@ var ToNode = &uast.ObjectToNode{
111110
"Return": "return",
112111
"RShift": ">>",
113112
"Sub": "-",
114-
"True": "true",
115113
"UAdd": "+",
116114
"USub": "-",
117115
"While": "while",

fixtures/assert_constant.py.native

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"lineno": 1,
1414
"msg": null,
1515
"test": {
16-
"LiteralValue": true,
16+
"LiteralValue": "True",
1717
"ast_type": "BoolLiteral",
1818
"col_offset": 8,
1919
"end_col_offset": 11,
@@ -30,7 +30,7 @@
3030
"lineno": 2,
3131
"msg": null,
3232
"test": {
33-
"LiteralValue": true,
33+
"LiteralValue": "True",
3434
"ast_type": "BoolLiteral",
3535
"col_offset": 8,
3636
"end_col_offset": 11,
@@ -54,7 +54,7 @@
5454
"s": "assert message"
5555
},
5656
"test": {
57-
"LiteralValue": true,
57+
"LiteralValue": "True",
5858
"ast_type": "BoolLiteral",
5959
"col_offset": 8,
6060
"end_col_offset": 11,

fixtures/assert_constant.py.uast

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Status: ok
22
Errors:
33
UAST:
44
Module {
5-
. Roles: File,Module
5+
. Roles: File
66
. Children: {
77
. . 0: Assert {
88
. . . Roles: Assert,Statement
@@ -23,7 +23,7 @@ Module {
2323
. . . }
2424
. . . Children: {
2525
. . . . 0: BoolLiteral {
26-
. . . . . Roles: Literal,Boolean,Expression,Primitive
26+
. . . . . Roles: Literal,Boolean,Expression
2727
. . . . . TOKEN "true"
2828
. . . . . StartPosition: {
2929
. . . . . . Offset: 7
@@ -61,7 +61,7 @@ Module {
6161
. . . }
6262
. . . Children: {
6363
. . . . 0: BoolLiteral {
64-
. . . . . Roles: Literal,Boolean,Expression,Primitive
64+
. . . . . Roles: Literal,Boolean,Expression
6565
. . . . . TOKEN "true"
6666
. . . . . StartPosition: {
6767
. . . . . . Offset: 20
@@ -98,7 +98,7 @@ Module {
9898
. . . }
9999
. . . Children: {
100100
. . . . 0: Str {
101-
. . . . . Roles: Literal,String,Expression,Primitive
101+
. . . . . Roles: Literal,String,Expression
102102
. . . . . TOKEN "assert message"
103103
. . . . . StartPosition: {
104104
. . . . . . Offset: 38
@@ -115,7 +115,7 @@ Module {
115115
. . . . . }
116116
. . . . }
117117
. . . . 1: BoolLiteral {
118-
. . . . . Roles: Literal,Boolean,Expression,Primitive
118+
. . . . . Roles: Literal,Boolean,Expression
119119
. . . . . TOKEN "true"
120120
. . . . . StartPosition: {
121121
. . . . . . Offset: 32
@@ -137,3 +137,4 @@ Module {
137137
. }
138138
}
139139

140+

fixtures/if.py.native

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"value": {
1616
"args": [
1717
{
18-
"LiteralValue": true,
18+
"LiteralValue": "True",
1919
"ast_type": "BoolLiteral",
2020
"col_offset": 11,
2121
"end_col_offset": 14,
@@ -46,7 +46,7 @@
4646
"lineno": 1,
4747
"orelse": [],
4848
"test": {
49-
"LiteralValue": true,
49+
"LiteralValue": "True",
5050
"ast_type": "BoolLiteral",
5151
"col_offset": 4,
5252
"end_col_offset": 7,
@@ -65,7 +65,7 @@
6565
"value": {
6666
"args": [
6767
{
68-
"LiteralValue": true,
68+
"LiteralValue": "True",
6969
"ast_type": "BoolLiteral",
7070
"col_offset": 11,
7171
"end_col_offset": 14,

native/python_package/python_driver/astimprove.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def visit_NameConstant(self, node):
486486
if "value" in node:
487487
repr_val = repr(node["value"])
488488
if repr_val in ("True", "False"):
489-
node.update({"LiteralValue": node["value"],
489+
node.update({"LiteralValue": "True" if node["value"] else "False",
490490
"ast_type": "BoolLiteral"})
491491
elif repr_val == "None":
492492
node.update({"LiteralValue": "None",

0 commit comments

Comments
 (0)