Skip to content

Commit

Permalink
AutoReport no longer checks for existing class
Browse files Browse the repository at this point in the history
  • Loading branch information
banesullivan committed Oct 21, 2023
1 parent 9a2def0 commit 6e5bb1f
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions scooby/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,7 @@ def to_dict(self) -> Dict[str, str]:
class AutoReport(Report):
"""Auto-generate a scooby.Report for a package.
This will check if the specified package has a ``Report`` class and use that or
fallback to generating a report based on the distribution requirements of the package.
This will generate a report based on the distribution requirements of the package.
"""

def __init__(self, module, additional=None, ncol=3, text_width=80, sort=False):
Expand All @@ -449,24 +448,17 @@ def __init__(self, module, additional=None, ncol=3, text_width=80, sort=False):
if isinstance(module, ModuleType):
module = module.__name__

try:
package = importlib.import_module(module)
if issubclass(package.Report, Report):
package.Report.__init__(
self, additional=additional, ncol=ncol, text_width=text_width, sort=sort
)
except (AttributeError, ImportError):
# Autogenerate from distribution requirements
core = [module, *get_distribution_dependencies(module)]
Report.__init__(
self,
additional=additional,
core=core,
optional=[],
ncol=ncol,
text_width=text_width,
sort=sort,
)
# Autogenerate from distribution requirements
core = [module, *get_distribution_dependencies(module)]
Report.__init__(
self,
additional=additional,
core=core,
optional=[],
ncol=ncol,
text_width=text_width,
sort=sort,
)


# This functionaliy might also be of interest on its own.
Expand Down

0 comments on commit 6e5bb1f

Please sign in to comment.