py2puml
py2puml copied to clipboard
support typing for typing.NamedTuple named tuples
Classes created with collections.namedtuple carry no type annotations.
from collections import namedtuple
Function = namedtuple('Function', ['name', 'module_Path'])
py2puml would generate the following documentation:
@startuml
class Function {
name: Any
module_path: Any
}
@enduml
However, it is also possible to create named tuple classes with typing.NamedTuple and specify type annotations:
from typing import NamedTuple, Tuple
class Function(NamedTuple):
'''
Models a function (calling or being called):
- it has a name
- it is hosted in a module, modeled by its path as a tuple of strings
'''
name: str
module_path: Tuple[str]
The expected PlantUML documentation would then be:
@startuml
class Function {
name: str
module_path: Tuple[str]
}
@enduml