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.
If I have the following code:
It fails (DCO031) because there is a return documented in the abstract method
get_name()
in classFooInterface
, 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.