Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Display parameters of the parent class #360

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions fire/helptext.py
Expand Up @@ -35,6 +35,8 @@

import itertools
import sys
import inspect
from types import FunctionType

from fire import completion
from fire import custom_descriptions
Expand Down Expand Up @@ -65,6 +67,7 @@ def HelpText(component, trace=None, verbose=False):
info = inspectutils.Info(component)
actions_grouped_by_kind = _GetActionsGroupedByKind(component, verbose=verbose)
spec = inspectutils.GetFullArgSpec(component)
spec.args = Checker(spec,component)
metadata = decorators.GetMetadata(component)

# Sections:
Expand Down Expand Up @@ -95,6 +98,42 @@ def HelpText(component, trace=None, verbose=False):
)


def Checker(spec,component):
"""
desc:
Checker funcition firstly checks type of component and afterthat
it extract all parent classes.
Return:
case 1: If there is any parent class it will return all parameters in list.
case 2: If there is no parent class so it will return only args list.
"""
if type(component) is not FunctionType and type(component) is not object:
try:
Inherit_classes_list=inspect.getmro(component)
if len(Inherit_classes_list)>2:
return ReturnParentParameters(Inherit_classes_list)
except AttributeError as e:
pass

return spec.args


def ReturnParentParameters(Inherit_classes_list):
"""
Inherit_classes_list: It is a list which have collection of parent classes.
Return: list of all parameters which is retrieved from parent classes.
"""
all_parameters = []

for classes in Inherit_classes_list:
argspec_tuple=inspect.getargspec(classes)
args_spec=argspec_tuple[0]
for parameter in args_spec[1:]:
all_parameters.append(parameter)

return all_parameters


def _NameSection(component, info, trace=None, verbose=False):
"""The "Name" section of the help string."""

Expand Down