-
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.
- Loading branch information
1 parent
7f03ab5
commit 4127eb4
Showing
5 changed files
with
25 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
//! Extract isort configuration settings from a pyproject.toml. | ||
|
||
use std::path::Path; | ||
|
||
use anyhow::Result; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::pyproject::Pyproject; | ||
|
||
/// 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>>, | ||
} | ||
|
||
pub fn parse_isort_options<P: AsRef<Path>>(path: P) -> Result<Option<Isort>> { | ||
let contents = std::fs::read_to_string(path)?; | ||
Ok(toml_edit::easy::from_str::<Pyproject>(&contents)? | ||
.tool | ||
.and_then(|tool| tool.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
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