-
Notifications
You must be signed in to change notification settings - Fork 959
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
Add a Flake8-to-Ruff configuration conversion tool #527
Conversation
This needs tests, and a strategy for actually distributing this tool. (It's just an example script in the repo right now.) |
src/flake8_to_ruff/parser.rs
Outdated
/// Parse a 'files-to-codes' mapping, mimicking Flake8's internal logic. | ||
/// | ||
/// See: https://github.com/PyCQA/flake8/blob/7dfe99616fc2f07c0017df2ba5fa884158f3ea8a/src/flake8/utils.py#L45 | ||
pub fn parse_files_to_codes_mapping(value: String) -> Result<Vec<StrCheckCodePair>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this was shockingly complicated, I guess it stems from INI being such a limited format. (This is basically a 1-to-1 port of the code from Flake8 for parsing the per-file-ignores.)
2296e34
to
119f549
Compare
119f549
to
3a5e717
Compare
@fsouza - Do you have any opinion on whether this should be distributed as...
|
(Merging for now, will expose in a separate PR.) |
Oh that's an interesting one. I'm thinking a separate PyPI package since the common use case will likely be a one-off (or people like me that can't really force everyone in the company to migrate and have to wrap it in something like flake8-ruff-wrapper lol). The reason I'm thinking that a separate PyPI package is better is because not everyone that uses ruff will use this tool? What do you think? |
Yeah that makes sense. I do want to split ruff into subcommands, but even then it's probably not worth including this as a subcommand on ruff itself given that it's more of a compatibility tool. |
"line-length" | "line_length" => match value.clone().unwrap().parse::<usize>() { | ||
Ok(line_length) => options.line_length = Some(line_length), | ||
Err(e) => eprintln!("Unable to parse '{key}' property: {e}"), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this should be max-line-length
/max_line_length
instead?
https://flake8.pycqa.org/en/latest/user/options.html#cmdoption-flake8-max-line-length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This PR adds a
flake8_to_ruff
command to generate a Ruffpyproject.toml
section from an existing Flake8 configuration file (setup.cfg, tox.ini, or .flake8).See: #414, #423.