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

code_gen.rs should take into account existing code preferences #454

Closed
charliermarsh opened this issue Oct 18, 2022 · 4 comments · Fixed by #1413
Closed

code_gen.rs should take into account existing code preferences #454

charliermarsh opened this issue Oct 18, 2022 · 4 comments · Fixed by #1413
Assignees

Comments

@charliermarsh
Copy link
Member

It'd be great to generate code that's aware of existing indentation and quotation preferences.

@leos
Copy link

leos commented Dec 27, 2022

I just ran into this as well with E712 on the following example code:

image = {"primary": 23}

if image["primary"] == True:
  print("hello!")

Running ruff 0.0.196 on this results in:

image = {"primary": 23}

if image['primary'] is True:
  print("hello!")

If the intent is to have ruff work with Black out of the box then it should default to double quotes - although obviously it would be nice to detect the quoting style before the fix as well.

@charliermarsh
Copy link
Member Author

Yeah agreed. It actually used to double-quote, but it required forking RustPython. I’ll look into it again and see if we can at least preserve double quotes, since it’d go a long way towards compatibility.

@charliermarsh
Copy link
Member Author

(Also: thank you for the clear example + version number etc.)

@charliermarsh
Copy link
Member Author

I'm gonna ship some improvements to this today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants