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

Commit 30d7fd7

Browse files
author
Juanjo Alvarez
committed
Removed OpMult from Incomplete Pow node. Marked type annotation nodes as incomplete
- Integration tests
1 parent e7f15e6 commit 30d7fd7

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

ANNOTATION.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Div'\] | OpDivide |
2323
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Mod'\] | OpMod |
2424
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='FloorDiv'\] | OpDivide, Incomplete |
25-
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Pow'\] | OpMultiply, Incomplete |
25+
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Pow'\] | Incomplete |
2626
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='MatMult'\] | OpMultiply, Incomplete |
2727
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='LShift'\] | OpBitwiseLeftShift |
2828
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='RShift'\] | OpBitwiseRightShift |
@@ -157,8 +157,8 @@
157157
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Print'\]/\*\[@internalRole\]\[@internalRole='nl'\] | CallPositionalArgument |
158158
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Print'\]/\*\[@internalRole\]\[@internalRole='values'\] | CallPositionalArgument |
159159
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Print'\]/\*\[@internalRole\]\[@internalRole='values'\]/\*\[\*\] | CallPositionalArgument |
160-
| /self::\*\[@InternalType='Module'\]//\*\[@internalRole\]\[@internalRole='annotation'\] | Comment |
161-
| /self::\*\[@InternalType='Module'\]//\*\[@internalRole\]\[@internalRole='returns'\] | Comment |
160+
| /self::\*\[@InternalType='Module'\]//\*\[@internalRole\]\[@internalRole='annotation'\] | Comment, Incomplete |
161+
| /self::\*\[@InternalType='Module'\]//\*\[@internalRole\]\[@internalRole='returns'\] | Comment, Incomplete |
162162
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='Ellipsis'\] | SimpleIdentifier |
163163
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='comprehension'\] | ForEach, Expression |
164164
| /self::\*\[@InternalType='Module'\]//\*\[@InternalType='comprehension'\]/\*\[@internalRole\]\[@internalRole='iter'\] | ForUpdate, Statement |

driver/normalizer/annotation.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ var AnnotationRules = On(Any).Self(
8080
On(HasInternalType(pyast.Mult)).Roles(OpMultiply),
8181
On(HasInternalType(pyast.Div)).Roles(OpDivide),
8282
On(HasInternalType(pyast.Mod)).Roles(OpMod),
83-
// TODO: currently without mapping in the UAST
8483
On(HasInternalType(pyast.FloorDiv)).Roles(OpDivide, Incomplete),
85-
On(HasInternalType(pyast.Pow)).Roles(OpMultiply, Incomplete),
84+
On(HasInternalType(pyast.Pow)).Roles(Incomplete),
8685
On(HasInternalType(pyast.MatMult)).Roles(OpMultiply, Incomplete),
8786

8887
// Bitwise operators
@@ -333,9 +332,9 @@ var AnnotationRules = On(Any).Self(
333332
// information by themselves and this we consider it comments (some preprocessors or linters can use
334333
// them, the runtimes ignore them). The TOKEN will take the annotation in the UAST node so
335334
// the information is keept in any case.
336-
// FIXME: change to Annotation when PR 112 is merged
337-
On(HasInternalRole("annotation")).Roles(Comment),
338-
On(HasInternalRole("returns")).Roles(Comment),
335+
// FIXME: need annotation or type UAST roles
336+
On(HasInternalRole("annotation")).Roles(Comment, Incomplete),
337+
On(HasInternalRole("returns")).Roles(Comment, Incomplete),
339338

340339
// Python very odd ellipsis operator. Has a special rule in tonoder synthetic tokens
341340
// map to load it with the token "PythonEllipsisOperator" and gets the role SimpleIdentifier

tests/aritmeticops.py.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ Module {
594594
. . . . . . . }
595595
. . . . . . }
596596
. . . . . . 1: Pow {
597-
. . . . . . . Roles: BinaryExpressionOp,OpMultiply,Incomplete
597+
. . . . . . . Roles: BinaryExpressionOp,Incomplete
598598
. . . . . . . TOKEN "**"
599599
. . . . . . . StartPosition: {
600600
. . . . . . . . Offset: 26

tests/declarations_annotated.py.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Module {
3232
. . . }
3333
. . . Children: {
3434
. . . . 0: Name {
35-
. . . . . Roles: SimpleIdentifier,Expression,Comment
35+
. . . . . Roles: SimpleIdentifier,Expression,Comment,Incomplete
3636
. . . . . TOKEN "int"
3737
. . . . . StartPosition: {
3838
. . . . . . Offset: 3
@@ -105,7 +105,7 @@ Module {
105105
. . . }
106106
. . . Children: {
107107
. . . . 0: Name {
108-
. . . . . Roles: SimpleIdentifier,Expression,Comment
108+
. . . . . Roles: SimpleIdentifier,Expression,Comment,Incomplete
109109
. . . . . TOKEN "str"
110110
. . . . . StartPosition: {
111111
. . . . . . Offset: 14

tests/functiondef_annotated.py.uast

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Module {
6767
. . . . . . . }
6868
. . . . . . . Children: {
6969
. . . . . . . . 0: Name {
70-
. . . . . . . . . Roles: SimpleIdentifier,Expression,Comment
70+
. . . . . . . . . Roles: SimpleIdentifier,Expression,Comment,Incomplete
7171
. . . . . . . . . TOKEN "int"
7272
. . . . . . . . . StartPosition: {
7373
. . . . . . . . . . Offset: 19
@@ -104,7 +104,7 @@ Module {
104104
. . . . . . . }
105105
. . . . . . . Children: {
106106
. . . . . . . . 0: Name {
107-
. . . . . . . . . Roles: SimpleIdentifier,Expression,Comment
107+
. . . . . . . . . Roles: SimpleIdentifier,Expression,Comment,Incomplete
108108
. . . . . . . . . TOKEN "str"
109109
. . . . . . . . . StartPosition: {
110110
. . . . . . . . . . Offset: 30
@@ -141,7 +141,7 @@ Module {
141141
. . . . . . . }
142142
. . . . . . . Children: {
143143
. . . . . . . . 0: Name {
144-
. . . . . . . . . Roles: SimpleIdentifier,Expression,Comment
144+
. . . . . . . . . Roles: SimpleIdentifier,Expression,Comment,Incomplete
145145
. . . . . . . . . TOKEN "MyType"
146146
. . . . . . . . . StartPosition: {
147147
. . . . . . . . . . Offset: 41
@@ -179,7 +179,7 @@ Module {
179179
. . . . . }
180180
. . . . }
181181
. . . . 2: Name {
182-
. . . . . Roles: SimpleIdentifier,Expression,Comment
182+
. . . . . Roles: SimpleIdentifier,Expression,Comment,Incomplete
183183
. . . . . TOKEN "Tuple"
184184
. . . . . StartPosition: {
185185
. . . . . . Offset: 52

0 commit comments

Comments
 (0)