@@ -3,7 +3,7 @@ use std::collections::{BTreeSet, HashMap};
33use anyhow:: Result ;
44use colored:: Colorize ;
55
6- use super :: black :: Black ;
6+ use super :: external_config :: ExternalConfig ;
77use super :: plugin:: Plugin ;
88use super :: { parser, plugin} ;
99use crate :: registry:: RuleSelector ;
@@ -23,7 +23,7 @@ use crate::warn_user;
2323
2424pub fn convert (
2525 config : & HashMap < String , HashMap < String , Option < String > > > ,
26- black : Option < & Black > ,
26+ external_config : & ExternalConfig ,
2727 plugins : Option < Vec < Plugin > > ,
2828) -> Result < Pyproject > {
2929 // Extract the Flake8 section.
@@ -377,7 +377,7 @@ pub fn convert(
377377 }
378378
379379 // Extract any settings from the existing `pyproject.toml`.
380- if let Some ( black) = black {
380+ if let Some ( black) = & external_config . black {
381381 if let Some ( line_length) = & black. line_length {
382382 options. line_length = Some ( * line_length) ;
383383 }
@@ -389,6 +389,19 @@ pub fn convert(
389389 }
390390 }
391391
392+ if let Some ( isort) = & external_config. isort {
393+ if let Some ( src_paths) = & isort. src_paths {
394+ match options. src . as_mut ( ) {
395+ Some ( src) => {
396+ src. extend ( src_paths. clone ( ) ) ;
397+ }
398+ None => {
399+ options. src = Some ( src_paths. clone ( ) ) ;
400+ }
401+ }
402+ }
403+ }
404+
392405 // Create the pyproject.toml.
393406 Ok ( Pyproject :: new ( options) )
394407}
@@ -401,6 +414,7 @@ mod tests {
401414
402415 use super :: super :: plugin:: Plugin ;
403416 use super :: convert;
417+ use crate :: flake8_to_ruff:: ExternalConfig ;
404418 use crate :: registry:: RuleSelector ;
405419 use crate :: rules:: pydocstyle:: settings:: Convention ;
406420 use crate :: rules:: { flake8_quotes, pydocstyle} ;
@@ -411,7 +425,7 @@ mod tests {
411425 fn it_converts_empty ( ) -> Result < ( ) > {
412426 let actual = convert (
413427 & HashMap :: from ( [ ( "flake8" . to_string ( ) , HashMap :: default ( ) ) ] ) ,
414- None ,
428+ & ExternalConfig :: default ( ) ,
415429 None ,
416430 ) ?;
417431 let expected = Pyproject :: new ( Options {
@@ -475,7 +489,7 @@ mod tests {
475489 "flake8" . to_string ( ) ,
476490 HashMap :: from ( [ ( "max-line-length" . to_string ( ) , Some ( "100" . to_string ( ) ) ) ] ) ,
477491 ) ] ) ,
478- None ,
492+ & ExternalConfig :: default ( ) ,
479493 Some ( vec ! [ ] ) ,
480494 ) ?;
481495 let expected = Pyproject :: new ( Options {
@@ -539,7 +553,7 @@ mod tests {
539553 "flake8" . to_string ( ) ,
540554 HashMap :: from ( [ ( "max_line_length" . to_string ( ) , Some ( "100" . to_string ( ) ) ) ] ) ,
541555 ) ] ) ,
542- None ,
556+ & ExternalConfig :: default ( ) ,
543557 Some ( vec ! [ ] ) ,
544558 ) ?;
545559 let expected = Pyproject :: new ( Options {
@@ -603,7 +617,7 @@ mod tests {
603617 "flake8" . to_string ( ) ,
604618 HashMap :: from ( [ ( "max_line_length" . to_string ( ) , Some ( "abc" . to_string ( ) ) ) ] ) ,
605619 ) ] ) ,
606- None ,
620+ & ExternalConfig :: default ( ) ,
607621 Some ( vec ! [ ] ) ,
608622 ) ?;
609623 let expected = Pyproject :: new ( Options {
@@ -667,7 +681,7 @@ mod tests {
667681 "flake8" . to_string ( ) ,
668682 HashMap :: from ( [ ( "inline-quotes" . to_string ( ) , Some ( "single" . to_string ( ) ) ) ] ) ,
669683 ) ] ) ,
670- None ,
684+ & ExternalConfig :: default ( ) ,
671685 Some ( vec ! [ ] ) ,
672686 ) ?;
673687 let expected = Pyproject :: new ( Options {
@@ -739,7 +753,7 @@ mod tests {
739753 Some ( "numpy" . to_string ( ) ) ,
740754 ) ] ) ,
741755 ) ] ) ,
742- None ,
756+ & ExternalConfig :: default ( ) ,
743757 Some ( vec ! [ Plugin :: Flake8Docstrings ] ) ,
744758 ) ?;
745759 let expected = Pyproject :: new ( Options {
@@ -810,7 +824,7 @@ mod tests {
810824 "flake8" . to_string ( ) ,
811825 HashMap :: from ( [ ( "inline-quotes" . to_string ( ) , Some ( "single" . to_string ( ) ) ) ] ) ,
812826 ) ] ) ,
813- None ,
827+ & ExternalConfig :: default ( ) ,
814828 None ,
815829 ) ?;
816830 let expected = Pyproject :: new ( Options {
0 commit comments