@@ -313,7 +313,7 @@ def _determine_package_enabled(self) -> EnableState:
313313 self .log (f"{ self .name } : always enabled" )
314314 return Package .EnableState (value = True , explicit = False )
315315
316- config_args = []
316+ config_args : list [ ConfigArgument ] = []
317317 primary_attr = None
318318 for attr_name in dir (self ):
319319 try :
@@ -329,21 +329,29 @@ def _determine_package_enabled(self) -> EnableState:
329329 # enabling the package
330330 continue
331331
332- config_args .append (attr )
333332 if attr .primary :
334333 assert primary_attr is None , (
335334 "Multiple primary ConfigArgument's, previously "
336- f"found { attr } "
335+ f"found { primary_attr } "
337336 )
338337 primary_attr = attr
338+ # The primary attribute, if it is explicitly set by the user,
339+ # should ultimately control whether the package is enabled or
340+ # disabled, so we check it first
341+ primary_val = getattr (self .cl_args , attr .spec .dest )
342+ if primary_val .cl_set :
343+ return Package .EnableState (
344+ value = bool (primary_val .value ), explicit = True
345+ )
346+ # The primary attribute is always checked first
347+ config_args .insert (0 , attr )
348+ else :
349+ config_args .append (attr )
339350
340351 assert primary_attr is not None , (
341352 f"Never found primary config argument for { self .name } "
342353 )
343354
344- # The primary attribute, if set, should ultimately control whether the
345- # package is enabled or disabled, so we check it first
346- config_args .insert (0 , primary_attr )
347355 for arg in config_args :
348356 cl_arg = getattr (self .cl_args , arg .spec .dest )
349357 if (val := cl_arg .value ) is not None :
0 commit comments