I have an interface defined as:
class IDefaultedRepo(IRepository):
"""Represents defaulted table in DB"""
def get_values_by_legalbdr(self, legalbdr: str):
raise NotImplementedError
However, this is not explicit enough, as I dont know what fields are returned. I would like to have something like:
class IDefaultedRepo(IRepository):
"""Represents defaulted table in DB"""
def get_values_by_legalbdr(self, legalbdr: str)->IDefaultedRepo.Result:
class Result(object):
def __init__(self, terminal, value, container):
self.terminal = terminal
self.value = value
self.container = container
raise NotImplementedError
But this throws a NameError, as Result class is not defined yet.
Is there any way to specify the return type of a function (so that inner member are accessible by dot .
operator), without explicitly create a result class for each function?
EDIT I didnt defined in their own module because I thought there would be too many of them with awkward and lengthy names. Defining an inner class would be nicer since it doesnt force to invent a new class name every time, also, since the return type is specific to a function it makes (?) sens to constraint the scope of the definition only to this function. But yeah, looks like I have to define them in a separate module