-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flake8_to_ruff: support
isort
options (#2082)
See: #1749.
- Loading branch information
1 parent
e11cf1b
commit 36fb8f7
Showing
7 changed files
with
82 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use super::black::Black; | ||
use super::isort::Isort; | ||
|
||
#[derive(Default)] | ||
pub struct ExternalConfig<'a> { | ||
pub black: Option<&'a Black>, | ||
pub isort: Option<&'a Isort>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//! Extract isort configuration settings from a pyproject.toml. | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
/// The [isort configuration](https://pycqa.github.io/isort/docs/configuration/config_files.html). | ||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Default)] | ||
pub struct Isort { | ||
#[serde(alias = "src-paths", alias = "src_paths")] | ||
pub src_paths: Option<Vec<String>>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
mod black; | ||
mod converter; | ||
mod external_config; | ||
mod isort; | ||
mod parser; | ||
mod plugin; | ||
mod pyproject; | ||
|
||
pub use black::parse_black_options; | ||
pub use converter::convert; | ||
pub use external_config::ExternalConfig; | ||
pub use plugin::Plugin; | ||
pub use pyproject::parse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::path::Path; | ||
|
||
use anyhow::Result; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::black::Black; | ||
use super::isort::Isort; | ||
|
||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct Tools { | ||
pub black: Option<Black>, | ||
pub isort: Option<Isort>, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct Pyproject { | ||
pub tool: Option<Tools>, | ||
} | ||
|
||
pub fn parse<P: AsRef<Path>>(path: P) -> Result<Pyproject> { | ||
let contents = std::fs::read_to_string(path)?; | ||
let pyproject = toml_edit::easy::from_str::<Pyproject>(&contents)?; | ||
Ok(pyproject) | ||
} |