getgrit / gritql

GritQL is a query language for searching, linting, and modifying code.

Home Page:https://docs.grit.io/

Repository from Github https://github.comgetgrit/gritqlRepository from Github https://github.comgetgrit/gritql

Python: Add import only adds one import to an existing import

eyurtsev opened this issue · comments

This may be related to the previous issue I filed or could be a separate edge case.

engine marzano(0.1)
language python

`x = 1` as $SELF where {
    add_import(source="pydantic", name="Self"),
    add_import(source="pydantic", name="pydantic1"),
}

Input

from pydantic import BaseModel, Extra, Field, root_validator   

x = 1

Current output (incorrect)

from pydantic import BaseModel, Extra, Field, root_validator, Self   

x = 1

Expected output

from pydantic import BaseModel, Extra, Field, root_validator, Self, pydantic1

x = 1

(Please let me know if I should be filing these against the standard lib instead)

And I have a workaround for this (I split the pattern into 2 separate patterns that I run sequentially)

Thanks for the report, this repo is fine.