@@ -303,7 +303,7 @@ pub fn resolve_configuration(
303
303
pyproject : & Path ,
304
304
relativity : Relativity ,
305
305
transformer : & dyn ConfigurationTransformer ,
306
- origin : Option < ConfigurationOrigin > ,
306
+ origin : ConfigurationOrigin ,
307
307
) -> Result < Configuration > {
308
308
let mut configurations = indexmap:: IndexMap :: new ( ) ;
309
309
let mut next = Some ( fs:: normalize_path ( pyproject) ) ;
@@ -321,7 +321,7 @@ pub fn resolve_configuration(
321
321
322
322
// Resolve the current path.
323
323
let version_strategy =
324
- if configurations. is_empty ( ) && matches ! ( origin, Some ( ConfigurationOrigin :: Ancestor ) ) {
324
+ if configurations. is_empty ( ) && matches ! ( origin, ConfigurationOrigin :: Ancestor ) {
325
325
// For configurations that are discovered by
326
326
// walking back from a file, we will attempt to
327
327
// infer the `target-version` if it is missing
@@ -383,7 +383,7 @@ fn resolve_scoped_settings<'a>(
383
383
pyproject : & ' a Path ,
384
384
relativity : Relativity ,
385
385
transformer : & dyn ConfigurationTransformer ,
386
- origin : Option < ConfigurationOrigin > ,
386
+ origin : ConfigurationOrigin ,
387
387
) -> Result < ( & ' a Path , Settings ) > {
388
388
let configuration = resolve_configuration ( pyproject, relativity, transformer, origin) ?;
389
389
let project_root = relativity. resolve ( pyproject) ;
@@ -400,16 +400,18 @@ pub fn resolve_root_settings(
400
400
origin : ConfigurationOrigin ,
401
401
) -> Result < Settings > {
402
402
let ( _project_root, settings) =
403
- resolve_scoped_settings ( pyproject, relativity, transformer, Some ( origin) ) ?;
403
+ resolve_scoped_settings ( pyproject, relativity, transformer, origin) ?;
404
404
Ok ( settings)
405
405
}
406
406
407
407
#[ derive( Debug , Clone , Copy ) ]
408
408
/// How the configuration is provided.
409
409
pub enum ConfigurationOrigin {
410
+ /// Origin is unknown to the caller
411
+ Unknown ,
410
412
/// User specified path to specific configuration file
411
413
UserSpecified ,
412
- /// User-level configuration
414
+ /// User-level configuration (e.g. in `~/.config/ruff/pyproject.toml`)
413
415
UserSettings ,
414
416
/// In parent or higher ancestor directory of path
415
417
Ancestor ,
@@ -442,7 +444,7 @@ pub fn python_files_in_path<'a>(
442
444
& pyproject,
443
445
Relativity :: Parent ,
444
446
transformer,
445
- None ,
447
+ ConfigurationOrigin :: Unknown ,
446
448
) ?;
447
449
resolver. add ( root, settings) ;
448
450
// We found the closest configuration.
@@ -597,7 +599,7 @@ impl ParallelVisitor for PythonFilesVisitor<'_, '_> {
597
599
& pyproject,
598
600
Relativity :: Parent ,
599
601
self . transformer ,
600
- None ,
602
+ ConfigurationOrigin :: Unknown ,
601
603
) {
602
604
Ok ( ( root, settings) ) => {
603
605
self . global . resolver . write ( ) . unwrap ( ) . add ( root, settings) ;
@@ -730,8 +732,12 @@ pub fn python_file_at_path(
730
732
if resolver. is_hierarchical ( ) {
731
733
for ancestor in path. ancestors ( ) {
732
734
if let Some ( pyproject) = settings_toml ( ancestor) ? {
733
- let ( root, settings) =
734
- resolve_scoped_settings ( & pyproject, Relativity :: Parent , transformer, None ) ?;
735
+ let ( root, settings) = resolve_scoped_settings (
736
+ & pyproject,
737
+ Relativity :: Parent ,
738
+ transformer,
739
+ ConfigurationOrigin :: Unknown ,
740
+ ) ?;
735
741
resolver. add ( root, settings) ;
736
742
break ;
737
743
}
0 commit comments