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

black_to_ruff: automated migration of black configuration settings #7541

Closed
4 tasks
konstin opened this issue Sep 20, 2023 · 3 comments
Closed
4 tasks

black_to_ruff: automated migration of black configuration settings #7541

konstin opened this issue Sep 20, 2023 · 3 comments
Labels
formatter Related to the formatter wish Not on the current roadmap; maybe in the future

Comments

@konstin
Copy link
Member

konstin commented Sep 20, 2023

Once the configuration for the formatter is implemented, we should write a tool, let's call it black_to_ruff, that automatically migrates as much of the black configuration to ruff configuration as possible. This should be based on or extend flake8_to_ruff which already reads some basic black config.

  • Read the black configuration: line-length, target-version, skip-magic-trailing-comma, preview, include, exclude
  • Find the relevant ruff configuration, pyproject.toml or ruff.toml`
  • Ignore redundant options, warn and ignore for conflicting options
  • rewrite (toml_edit) the toml configuration file
@konstin konstin added the formatter Related to the formatter label Sep 20, 2023
@konstin konstin changed the title blake_to_ruff: automated migration of black configuration settings black_to_ruff: automated migration of black configuration settings Sep 20, 2023
@MichaReiser
Copy link
Member

We may want to consider a ruff init or ruff migrate command that is part of ruff instead of falke8_to_ruff which is an independent binary

@charliermarsh
Copy link
Member

I'm sort of medium on this, based on my experience with flake8-to-ruff. It's a nice idea in theory but ends up being a pain to translate from another tool's settings to our own (for example, how would we do includes and excludes, where Black uses a single regular expression?). And the payoff hasn't been great since it's a one-time tool. (Perhaps the discoverability is low given that it's a separate package and not a subcommand.) My hope is that our configuration is close enough to Black's that the migration should be trivial to do by-hand...

This isn't a hard no, but rather, I question whether it's a worthwhile investment (upfront and in ongoing maintenance) vs. other areas.

@MichaReiser MichaReiser added the wish Not on the current roadmap; maybe in the future label Oct 27, 2023
@charliermarsh
Copy link
Member

I'm gonna close this as I'd prefer not to invest effort here. There are few enough configuration knobs that it's probably easy to just port the configuration than to download and figure out how to run a separate tool :)

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter wish Not on the current roadmap; maybe in the future
Projects
None yet
Development

No branches or pull requests

3 participants