Skip to content

support optional typing #50

@lucsorel

Description

@lucsorel

py2puml fails to inspect a dataclass using Optional as follows:

from dataclasses import dataclass
from typing import Optional
@dataclass
class MyData:
  data: Optional[bool]

ValueError: Could not resolve type typing.Union in module <module 'tests.modules.withoptional' from '.../py2puml/tests/modules/withoptional.py'>: it needs to be imported explicitly.

It is because Optional[bool] is dynamically converted into Union[bool, None] without adding both typing.Union and typing.Nonetype in the module wrapped by the ModuleResolver.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions