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

Error DCO031 in abstract methods #24

Open
ni-co-la opened this issue Dec 1, 2023 · 0 comments
Open

Error DCO031 in abstract methods #24

ni-co-la opened this issue Dec 1, 2023 · 0 comments

Comments

@ni-co-la
Copy link

ni-co-la commented Dec 1, 2023

If I have the following code:

from abc import ABCMeta, abstractmethod
from typing import override

def main() -> None:
    """Main."""
    print('main')

    foo = FooImpl()
    print(foo.get_name())

class FooInterface(metaclass=ABCMeta):
    """Interface Foo."""

    @abstractmethod
    def get_name(self) -> str:
        """Return name.

        Returns:
            str: Name
        """

class FooImpl(FooInterface):
    """Foo."""

    @override
    def get_name(self) -> str:
        """Return name.

        Returns:
            str: Name
        """
        return 'Foo'

if __name__ == '__main__':
    main()

It fails (DCO031) because there is a return documented in the abstract method get_name() in class FooInterface, but there is no return implemented.
The documented return value is necessary, as it fully describes the abstract method and how it can be used.
Every class implementing the interface, shall know what the expected return value needs to be.

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