Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

DAR201 Request for Missing Return on abstractmethod #185

Open
erikvanderwerf opened this issue Nov 23, 2021 · 1 comment
Open

DAR201 Request for Missing Return on abstractmethod #185

erikvanderwerf opened this issue Nov 23, 2021 · 1 comment

Comments

@erikvanderwerf
Copy link

erikvanderwerf commented Nov 23, 2021

from abc import ABC, abstractmethod


class MySpam(ABC):
    """Docstring."""

    @abstractmethod
    def spam(self) -> str:
        """Spam."""                        <-- Missing
        raise NotImplementedError()

    def sausage(self) -> float:
        """Sausage."""                     <-- 13
        return 0.4


def eggs() -> int:
    """Eggs."""                            <-- 18
    return 3
$ flake8 --select DAR main.py 
main.py:13:1: DAR201 Missing "Returns" in Docstring: - return
main.py:18:1: DAR201 Missing "Returns" in Docstring: - return

$ flake8 --select DAR --strictness full main.py 
main.py:13:1: DAR201 Missing "Returns" in Docstring: - return
main.py:18:1: DAR201 Missing "Returns" in Docstring: - return

I would like to see a DAR201 (or new error) for a missing Returns docstring section on methods decorated as @abstractmethod. This is different than #54, as that issue related to not requiring an actual return statement in code, whereas this is strictly about the docstring. I have also checked that missing parameters are reported, as expected (not shown above).

This helps because it will require superclass interfaces to declare what their implementors should return.

@joshua-cannon-techlabs
Copy link

I agree with this. But to add on I think it can only be reported if there's a return type annotation, as not all methods return.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants