@@ -317,14 +317,20 @@ def add_argument(self, *name_or_flags, **kwargs) -> None:
317317 variable = get_argument_name (* name_or_flags ).replace ("-" , "_" )
318318 self .argument_buffer [variable ] = (name_or_flags , kwargs )
319319
320+ def _is_ignored_argument (self , variable : str , annotations : Optional [dict [str , Any ]] = None ) -> bool :
321+ annotations = self ._annotations_with_extras if annotations is None else annotations
322+ if variable in annotations :
323+ var_type = annotations [variable ]
324+ if typing_get_origin (var_type ) is Annotated and _TapIgnoreMarker in typing_get_args (var_type ):
325+ return True
326+ return False
327+
320328 def _add_arguments (self ) -> None :
321329 """Add arguments to self in the order they are defined as class variables (so the help string is in order)."""
322330 # Add class variables (in order)
323331 for variable in self .class_variables :
324- if variable in self ._annotations_with_extras :
325- var_type = self ._annotations_with_extras [variable ]
326- if typing_get_origin (var_type ) is Annotated and _TapIgnoreMarker in typing_get_args (var_type ):
327- continue
332+ if self ._is_ignored_argument (variable ):
333+ continue
328334
329335 if variable in self .argument_buffer :
330336 name_or_flags , kwargs = self .argument_buffer [variable ]
@@ -335,6 +341,8 @@ def _add_arguments(self) -> None:
335341 # Add any arguments that were added manually in configure but aren't class variables (in order)
336342 for variable , (name_or_flags , kwargs ) in self .argument_buffer .items ():
337343 if variable not in self .class_variables :
344+ if self ._is_ignored_argument (variable ):
345+ continue
338346 self ._add_argument (* name_or_flags , ** kwargs )
339347
340348 def process_args (self ) -> None :
@@ -562,7 +570,7 @@ def _get_annotations(self, include_extras: bool = False) -> dict[str, Any]:
562570 extract_func = lambda super_class : dict (get_type_hints (super_class , include_extras = include_extras ))
563571 )
564572
565- def _get_class_variables (self ) -> dict :
573+ def _get_class_variables (self , exclude_tap_ignores : bool = True ) -> dict :
566574 """Returns a dictionary mapping class variables names to their additional information."""
567575 class_variable_names = {** self ._get_annotations (), ** self ._get_class_dict ()}.keys ()
568576
@@ -587,7 +595,13 @@ def _get_class_variables(self) -> dict:
587595 class_variables = {}
588596 for variable in class_variable_names :
589597 class_variables [variable ] = {"comment" : "" }
590-
598+ if exclude_tap_ignores :
599+ extra_annotations = self ._get_annotations (include_extras = True )
600+ return {
601+ var : data
602+ for var , data in class_variables .items ()
603+ if not self ._is_ignored_argument (var , extra_annotations )
604+ }
591605 return class_variables
592606
593607 def _get_argument_names (self ) -> set [str ]:
0 commit comments