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

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

Closed
pawamoy opened this issue May 22, 2024 · 0 comments
Closed

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

pawamoy opened this issue May 22, 2024 · 0 comments
Assignees

Comments

@pawamoy
Copy link
Member

pawamoy commented May 22, 2024

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.

@pawamoy pawamoy added the feature New feature or request label May 22, 2024
@pawamoy pawamoy self-assigned this May 22, 2024
@pawamoy pawamoy removed the feature New feature or request label May 22, 2024
pawamoy added a commit that referenced this issue Jun 8, 2024
@pawamoy pawamoy closed this as completed Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant