@@ -106,17 +106,7 @@ def is_used(self) -> bool:
106
106
for dep in self .get_test_deps (unconditional = True ):
107
107
if is_dep_in_any_group (dep ):
108
108
return True
109
- config_spec = self .get_config_spec ()
110
- for config_item in config_spec .config_items :
111
- if not config_item .managed :
112
- continue
113
-
114
- for path , entry in config_item .root .items ():
115
- file_manager = config_spec .file_manager_by_relative_path [path ]
116
- if file_manager .__contains__ (entry .keys ):
117
- return True
118
-
119
- return False
109
+ return self .is_config_present ()
120
110
121
111
def add_dev_deps (self ) -> None :
122
112
add_deps_to_group (self .get_dev_deps (), "dev" )
@@ -234,6 +224,20 @@ def preferred_file_manager(self) -> KeyValueFileManager:
234
224
"""If there is no currently active config file, this is the preferred one."""
235
225
return PyprojectTOMLManager ()
236
226
227
+ def is_config_present (self ) -> bool :
228
+ """Whether any of the tool's managed config sections are present."""
229
+ config_spec = self .get_config_spec ()
230
+ for config_item in config_spec .config_items :
231
+ if not config_item .managed :
232
+ continue
233
+
234
+ for path , entry in config_item .root .items ():
235
+ file_manager = config_spec .file_manager_by_relative_path [path ]
236
+ if file_manager .__contains__ (entry .keys ):
237
+ return True
238
+
239
+ return False
240
+
237
241
def add_configs (self ) -> None :
238
242
"""Add the tool's configuration sections."""
239
243
# Principles:
0 commit comments