Skip to content

RedBaron confuse relative path to ellipsis in from_imports #213

Description

@Aluriak

Hi !

The following code:

import redbaron
import json
print(json.dumps(redbaron.RedBaron('from ...util import properties').fst(), indent=4))

returns:

[
    {
        "type": "from_import",
        "first_formatting": [
            {
                "type": "space",
                "value": " "
            }
        ],
        "value": [
            {
                "type": "ellipsis",
                "first_formatting": [],
                "second_formatting": []
            },
            {
                "type": "name",
                "value": "util"
            }
        ],
        "second_formatting": [
            {
                "type": "space",
                "value": " "
            }
        ],
        "third_formatting": [
            {
                "type": "space",
                "value": " "
            }
        ],
        "targets": [
            {
                "type": "name_as_name",
                "value": "properties",
                "target": "",
                "first_formatting": [],
                "second_formatting": []
            }
        ]
    }
]

Where we can clearly see the ellipsis being parsed from the from_import line.

To me, this seems to be a misparse.

Note that increasing the dot number will still yield an ellispsis. To get N ellispsis, provide N*3 dots.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions