Skip to content

docstring.py assumes that a method of class should NOT return a value #1123

@NimaSarajpoor

Description

@NimaSarajpoor

If a method (of a class) returns a value, then the else part in the following lines from docstring.py:

stumpy/docstring.py

Lines 26 to 33 in ce05903

if class_name is None:
params_section = re.findall(
r"(?<=Parameters)(.*)(?=Returns)", docstring, re.DOTALL
)[0]
else:
params_section = re.findall(r"(?<=Parameters)(.*)", docstring, re.DOTALL)[0]
args = re.findall(r"(\w+)\s+\:", params_section)

captures that output variable name from its docstring and includes it in the args. This issue was initially exposed when a class with method __call__ was added in PR #1118. One suggestion provided in this comment was:

Given that this is an extreme case, it almost feels like it merits its on elif condition that specifically handles the specific _call_ case?

I think the real question we should ask ourselves is: "Should we treat methods like regular functions, meaning they can return value?

I understand that all methods of all classes in STUMPY main branch currently return nothing ("None"). However, I think it is not unreasonable to assume that, in future, a class might be added that has a method that returns a value. So, maybe we should revise the else part in the code above ??

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions