Skip to content

cannot use types defined in preceding classes as type annotations #39

@robinzyb

Description

@robinzyb

Dear Developers,
I have encountered the following error when I used py2puml.

I was trying to draw uml diagram of the deepmd package with the command,

py2puml deepmd/train deepmd.train

I have the error messages:

Traceback (most recent call last):
  File "/data/ybzhuang/conda/env/dpff/bin/py2puml", line 8, in <module>
    sys.exit(run())
  File "/data/ybzhuang/conda/env/dpff/lib/python3.9/site-packages/py2puml/cli.py", line 17, in run
    print(''.join(py2puml(args.path, args.module)))
  File "/data/ybzhuang/conda/env/dpff/lib/python3.9/site-packages/py2puml/py2puml.py", line 12, in py2puml
    inspect_package(
  File "/data/ybzhuang/conda/env/dpff/lib/python3.9/site-packages/py2puml/inspection/inspectpackage.py", line 20, in inspect_package
    inspect_module(
  File "/data/ybzhuang/conda/env/dpff/lib/python3.9/site-packages/py2puml/inspection/inspectmodule.py", line 60, in inspect_module
    inspect_domain_definition(definition_type, root_module_name, domain_items_by_fqn, domain_relations)
  File "/data/ybzhuang/conda/env/dpff/lib/python3.9/site-packages/py2puml/inspection/inspectmodule.py", line 47, in inspect_domain_definition
    inspect_class_type(
  File "/data/ybzhuang/conda/env/dpff/lib/python3.9/site-packages/py2puml/inspection/inspectclass.py", line 99, in inspect_class_type
    attributes = inspect_static_attributes(
  File "/data/ybzhuang/conda/env/dpff/lib/python3.9/site-packages/py2puml/inspection/inspectclass.py", line 78, in inspect_static_attributes
    attr_type, full_namespaced_definitions = shorten_compound_type_annotation(attr_raw_type, module_resolver)
  File "/data/ybzhuang/conda/env/dpff/lib/python3.9/site-packages/py2puml/parsing/astvisitors.py", line 215, in shorten_compound_type_annotation
    raise ValueError(f'Could not resolve type {compound_type_part} in module {module_resolver.module}: it needs to be imported explicitely.')
ValueError: Could not resolve type deepmd.train.run_options.HVD in module <module 'deepmd.train.run_options' from '/data/ybzhuang/repositories/deepmd-kit/deepmd/train/run_options.py'>: it needs to be imported explicitely.

How should I bypass this implicit-typing errors?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions