Skip to content

Error DCO031 in abstract methods Β #24

@99njaggi

Description

@99njaggi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions