Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of failing re-write that involves add_import #447

Open
eyurtsev opened this issue Aug 6, 2024 · 1 comment
Open

Example of failing re-write that involves add_import #447

eyurtsev opened this issue Aug 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@eyurtsev
Copy link

eyurtsev commented Aug 6, 2024

Not sure what's actually causing the failure, but failure appears when there are no other nodes except for the node to be changed

language python

class_definition($name, $body) as $C where {
    $name <: `Config`,
    $body <: block($statements),
    $t = "",
    $statements <: some bubble($t) assignment(left=$x, right=$y) as $A where {    
        $t += `$x=$y,`

    },
    $C => `ConfigDict($t)`,
    add_import(source="pydantic", name="ConfigDict")
}

Fails on this code:

class Config:
  a: int = 2
  b: float = 5

Transforms to:

from pydantic import ConfigDict

class Config:
  a: int = 2
  b: float = 5

But works correctly if i add a comment node

# hello  <--- Addnig a comment
class Config:
  a: int = 2
  b: float = 5

With output:

from pydantic import ConfigDict

# hello
ConfigDict(a=2,b=5,)
@morgante morgante added the bug Something isn't working label Aug 6, 2024
@morgante
Copy link
Contributor

morgante commented Aug 6, 2024

It seems like this is only an issue in the studio, as it works fine in a test.

In realiy, I assume files with only a single node are very rare.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants