Код: Выделить всё
def q( type, func : Callable[[type], str]) -> bool:
nonlocal text
if isinstance( node, type ):
text = func( node )
return True
return False
Код: Выделить всё
_ = \
q( doc_tree.Block, self._get_block ) or \
q( doc_tree.Section, self._get_section ) or \
q( doc_tree.Text, self._get_text ) or \
fail()
Код: Выделить всё
def _get_section( self, node : doc_tree.Section ) -> str:
Код: Выделить всё
error: Argument 2 to "q" has incompatible type "Callable[[Section], str]"; expected "Callable[[type], str]"
Подробнее здесь: https://stackoverflow.com/questions/566 ... -the-first