@@ -339,7 +339,8 @@ def __init__(
339
339
"was found inside. This can happen when [settings] is used as the config "
340
340
"header instead of [isort]. "
341
341
"See: https://pycqa.github.io/isort/docs/configuration/config_files"
342
- "#custom-config-files for more information."
342
+ "#custom-config-files for more information." ,
343
+ stacklevel = 2 ,
343
344
)
344
345
elif settings_path :
345
346
if not os .path .exists (settings_path ):
@@ -407,7 +408,8 @@ def __init__(
407
408
f"Default to { section_name } if unsure."
408
409
"\n \n "
409
410
"See: https://pycqa.github.io/isort/"
410
- "#custom-sections-and-ordering."
411
+ "#custom-sections-and-ordering." ,
412
+ stacklevel = 2 ,
411
413
)
412
414
else :
413
415
combined_config [section_name ] = frozenset (value )
@@ -419,7 +421,8 @@ def __init__(
419
421
" included in `sections` config option:"
420
422
f" { combined_config .get ('sections' , SECTION_DEFAULTS )} .\n \n "
421
423
"See: https://pycqa.github.io/isort/"
422
- "#custom-sections-and-ordering."
424
+ "#custom-sections-and-ordering." ,
425
+ stacklevel = 2 ,
423
426
)
424
427
if key .startswith (IMPORT_HEADING_PREFIX ):
425
428
import_headings [key [len (IMPORT_HEADING_PREFIX ) :].lower ()] = str (value )
@@ -442,7 +445,8 @@ def __init__(
442
445
warn (
443
446
f"`sections` setting includes { section } , but no known_{ section .lower ()} "
444
447
"is defined. "
445
- f"The following known_SECTION config options are defined: { config_keys } ."
448
+ f"The following known_SECTION config options are defined: { config_keys } ." ,
449
+ stacklevel = 2 ,
446
450
)
447
451
448
452
if "directory" not in combined_config :
@@ -495,7 +499,8 @@ def __init__(
495
499
"W0503: Deprecated config options were used: "
496
500
f"{ ', ' .join (deprecated_options_used )} ."
497
501
"Please see the 5.0.0 upgrade guide: "
498
- "https://pycqa.github.io/isort/docs/upgrade_guides/5.0.0.html"
502
+ "https://pycqa.github.io/isort/docs/upgrade_guides/5.0.0.html" ,
503
+ stacklevel = 2 ,
499
504
)
500
505
501
506
if known_other :
@@ -777,7 +782,10 @@ def _find_config(path: str) -> Tuple[str, Dict[str, Any]]:
777
782
potential_config_file , CONFIG_SECTIONS [config_file_name ]
778
783
)
779
784
except Exception :
780
- warn (f"Failed to pull configuration information from { potential_config_file } " )
785
+ warn (
786
+ f"Failed to pull configuration information from { potential_config_file } " ,
787
+ stacklevel = 2 ,
788
+ )
781
789
config_data = {}
782
790
if config_data :
783
791
return (current_directory , config_data )
@@ -814,7 +822,10 @@ def find_all_configs(path: str) -> Trie:
814
822
potential_config_file , CONFIG_SECTIONS [config_file_name ]
815
823
)
816
824
except Exception :
817
- warn (f"Failed to pull configuration information from { potential_config_file } " )
825
+ warn (
826
+ f"Failed to pull configuration information from { potential_config_file } " ,
827
+ stacklevel = 2 ,
828
+ )
818
829
config_data = {}
819
830
820
831
if config_data :
0 commit comments