diff --git a/driver/normalizer/normalizer.go b/driver/normalizer/normalizer.go index a56af556..047adae5 100644 --- a/driver/normalizer/normalizer.go +++ b/driver/normalizer/normalizer.go @@ -444,7 +444,6 @@ var Normalizers = []Mapping{ // FIXME: no position for the module (path) in the native AST, only when the import starts numLevel: Var("level"), path: Var("module"), - joined: Var("joined"), prefix: "../", }, }), @@ -468,7 +467,6 @@ var Normalizers = []Mapping{ "Name": OpPrependPath{ numLevel: Var("level"), path: Var("module"), - joined: Var("joined"), prefix: "../", }, }), diff --git a/driver/normalizer/util.go b/driver/normalizer/util.go index f206d728..13589e77 100644 --- a/driver/normalizer/util.go +++ b/driver/normalizer/util.go @@ -19,7 +19,6 @@ func num2dots(n nodes.Value, prefix string) nodes.Value { type OpPrependPath struct { numLevel Op path Op - joined Op prefix string } @@ -58,16 +57,7 @@ func (op OpPrependPath) Construct(st *State, n nodes.Node) (nodes.Node, error) { if err != nil || path == nil { return n, err } - - joined := string(prependVal.(nodes.String)) + string(path.(nodes.String)) - op.joined = String(joined) - - v, err := op.joined.Construct(st, n) - if err != nil { - return nil, err - } - - return v, nil + return prependVal.(nodes.String) + path.(nodes.String), nil } type OpLevelDotsNumConv struct { diff --git a/fixtures/u2_import_relativepath.py b/fixtures/u2_import_relativepath.py index 6b1c1fb0..1569ecdd 100644 --- a/fixtures/u2_import_relativepath.py +++ b/fixtures/u2_import_relativepath.py @@ -1,3 +1,3 @@ from .a import b -from ..c import e +from ..c.d import e from ... import f diff --git a/fixtures/u2_import_relativepath.py.native b/fixtures/u2_import_relativepath.py.native index c5fc075a..a3bbe9a0 100644 --- a/fixtures/u2_import_relativepath.py.native +++ b/fixtures/u2_import_relativepath.py.native @@ -21,11 +21,9 @@ { 'ast_type': "ImportFrom", 'col_offset': 1, - 'end_col_offset': 9, - 'end_lineno': 2, level: 2, lineno: 2, - module: "c", + module: "c.d", names: [ { asname: ~, diff --git a/fixtures/u2_import_relativepath.py.sem.uast b/fixtures/u2_import_relativepath.py.sem.uast index f9d9b2f5..fb6c24bd 100644 --- a/fixtures/u2_import_relativepath.py.sem.uast +++ b/fixtures/u2_import_relativepath.py.sem.uast @@ -36,11 +36,6 @@ line: 2, col: 1, }, - end: { '@type': "uast:Position", - offset: 25, - line: 2, - col: 9, - }, }, All: false, Names: [ @@ -51,14 +46,14 @@ }, ], Path: { '@type': "uast:Identifier", - Name: "../../c", + Name: "../../c.d", }, Target: ~, }, { '@type': "uast:RuntimeImport", '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 35, + offset: 37, line: 3, col: 1, }, diff --git a/fixtures/u2_import_relativepath.py.uast b/fixtures/u2_import_relativepath.py.uast index 937c9349..44c68abe 100644 --- a/fixtures/u2_import_relativepath.py.uast +++ b/fixtures/u2_import_relativepath.py.uast @@ -50,18 +50,13 @@ line: 2, col: 1, }, - end: { '@type': "uast:Position", - offset: 25, - line: 2, - col: 9, - }, }, level: { '@type': "ImportFrom.level", '@token': "..", '@role': [Import, Incomplete], }, module: { '@type': "ImportFrom.module", - '@token': "c", + '@token': "c.d", '@role': [Identifier, Import, Pathname], }, names: { '@type': "ImportFrom.names", @@ -85,7 +80,7 @@ '@role': [Declaration, Import, Statement], '@pos': { '@type': "uast:Positions", start: { '@type': "uast:Position", - offset: 35, + offset: 37, line: 3, col: 1, }, diff --git a/fixtures/u2_import_subsymbol_alias.py b/fixtures/u2_import_subsymbol_alias.py index 18641e1b..5db06cb7 100644 --- a/fixtures/u2_import_subsymbol_alias.py +++ b/fixtures/u2_import_subsymbol_alias.py @@ -1,2 +1,2 @@ import x.y as z -from a import b as c +from a.b import c as d diff --git a/fixtures/u2_import_subsymbol_alias.py.native b/fixtures/u2_import_subsymbol_alias.py.native index dbebb81f..80c14d01 100644 --- a/fixtures/u2_import_subsymbol_alias.py.native +++ b/fixtures/u2_import_subsymbol_alias.py.native @@ -17,16 +17,14 @@ { 'ast_type': "ImportFrom", 'col_offset': 1, - 'end_col_offset': 7, - 'end_lineno': 2, level: 0, lineno: 2, - module: "a", + module: "a.b", names: [ { - asname: "c", + asname: "d", 'ast_type': "alias", - name: "b", + name: "c", }, ], }, diff --git a/fixtures/u2_import_subsymbol_alias.py.sem.uast b/fixtures/u2_import_subsymbol_alias.py.sem.uast index dc50918b..78e608ee 100644 --- a/fixtures/u2_import_subsymbol_alias.py.sem.uast +++ b/fixtures/u2_import_subsymbol_alias.py.sem.uast @@ -32,11 +32,6 @@ line: 2, col: 1, }, - end: { '@type': "uast:Position", - offset: 22, - line: 2, - col: 7, - }, }, All: false, Names: [ @@ -44,15 +39,15 @@ '@pos': { '@type': "uast:Positions", }, Name: { '@type': "uast:Identifier", - Name: "c", + Name: "d", }, Node: { '@type': "uast:Identifier", - Name: "b", + Name: "c", }, }, ], Path: { '@type': "uast:Identifier", - Name: "a", + Name: "a.b", }, Target: ~, }, diff --git a/fixtures/u2_import_subsymbol_alias.py.uast b/fixtures/u2_import_subsymbol_alias.py.uast index 6b25dbb5..2367f201 100644 --- a/fixtures/u2_import_subsymbol_alias.py.uast +++ b/fixtures/u2_import_subsymbol_alias.py.uast @@ -37,30 +37,25 @@ line: 2, col: 1, }, - end: { '@type': "uast:Position", - offset: 22, - line: 2, - col: 7, - }, }, level: { '@type': "ImportFrom.level", '@token': "", '@role': [Import, Incomplete], }, module: { '@type': "ImportFrom.module", - '@token': "a", + '@token': "a.b", '@role': [Identifier, Import, Pathname], }, names: { '@type': "ImportFrom.names", '@role': [Identifier, Import, Incomplete, Pathname], 'name_list': [ { '@type': "alias", - '@token': "b", + '@token': "c", '@role': [Identifier, Import, Pathname], '@pos': { '@type': "uast:Positions", }, asname: { '@type': "alias.asname", - '@token': "c", + '@token': "d", '@role': [Alias, Identifier, Import, Pathname], }, },