Skip to content

refactor: Change the logic for the lines property of objects #271

@pawamoy

Description

@pawamoy

Currently, an object with either lineno or endlineno being None will return the whole module lines as source. This only makes sense for modules (modules don't have "line numbers", so their lineno and endlineno attributes are None). For classes, functions and attributes, it really feels wrong to return the whole module's code. Instead, we should return an empty list.

So instead of this:

        if self.lineno is None or self.endlineno is None:
            return lines

...we should do this:

        if self.lineno is None or self.endlineno is None:
            return []

This would have at least prevented mkdocstrings/python#163.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions