Skip to content

Commit 96182f8

Browse files
committed
remove the need_tap argument since it is not used
1 parent 03c9dc4 commit 96182f8

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/tap/tap.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,7 @@ def parse_args(
483483
return self
484484

485485
@classmethod
486-
def _get_from_self_and_super(
487-
cls, extract_func: Callable[[type], dict], *, need_tap_cls: bool = True,
488-
) -> Union[Dict[str, Any], Dict]:
486+
def _get_from_self_and_super( cls, extract_func: Callable[[type], dict]) -> Union[Dict[str, Any], Dict]:
489487
"""Returns a dictionary mapping variable names to values.
490488
491489
Variables and values are extracted from classes using key starting
@@ -496,7 +494,6 @@ def _get_from_self_and_super(
496494
Super classes are traversed through breadth first search.
497495
498496
:param extract_func: A function that extracts from a class a dictionary mapping variables to values.
499-
:param need_tap_cls: If False, variables from the Tap and ArgumentParser classes are ignored.
500497
:return: A dictionary mapping variable names to values from the class dict.
501498
"""
502499
visited = set()
@@ -506,10 +503,7 @@ def _get_from_self_and_super(
506503
while len(super_classes) > 0:
507504
super_class = super_classes.pop(0)
508505

509-
if not need_tap_cls and super_class is Tap:
510-
break
511-
512-
if super_class not in visited and issubclass(super_class, Tap):
506+
if super_class not in visited and issubclass(super_class, Tap) and super_class is not Tap:
513507
super_dictionary = extract_func(super_class)
514508

515509
# Update only unseen variables to avoid overriding subclass values
@@ -527,8 +521,7 @@ def _get_from_self_and_super(
527521
def _get_class_dict(self) -> Dict[str, Any]:
528522
"""Returns a dictionary mapping class variable names to values from the class dict."""
529523
class_dict = self._get_from_self_and_super(
530-
extract_func=lambda super_class: dict(getattr(super_class, "__dict__", dict())),
531-
need_tap_cls=False,
524+
extract_func=lambda super_class: dict(getattr(super_class, "__dict__", dict()))
532525
)
533526
class_dict = {
534527
var: val
@@ -545,18 +538,15 @@ def _get_class_dict(self) -> Dict[str, Any]:
545538
def _get_annotations(self) -> Dict[str, Any]:
546539
"""Returns a dictionary mapping variable names to their type annotations."""
547540
return self._get_from_self_and_super(
548-
extract_func=lambda super_class: dict(get_type_hints(super_class)),
549-
need_tap_cls=False,
541+
extract_func=lambda super_class: dict(get_type_hints(super_class))
550542
)
551543

552544
def _get_class_variables(self) -> dict:
553545
"""Returns a dictionary mapping class variables names to their additional information."""
554546
class_variable_names = {**self._get_annotations(), **self._get_class_dict()}.keys()
555547

556548
try:
557-
class_variables = self._get_from_self_and_super(
558-
extract_func=get_class_variables, need_tap_cls=False,
559-
)
549+
class_variables = self._get_from_self_and_super(extract_func=get_class_variables)
560550

561551
# Handle edge-case of source code modification while code is running
562552
variables_to_add = class_variable_names - class_variables.keys()
@@ -597,7 +587,6 @@ def as_dict(self) -> Dict[str, Any]:
597587
self_dict = self.__dict__
598588
class_dict = self._get_from_self_and_super(
599589
extract_func=lambda super_class: dict(getattr(super_class, "__dict__", dict())),
600-
need_tap_cls=False,
601590
)
602591
class_dict = {key: val for key, val in class_dict.items() if key not in self_dict}
603592
stored_dict = {**self_dict, **class_dict}

0 commit comments

Comments
 (0)