Skip to content

feat: Resolve aliasing for imports #24

@Masara

Description

@Masara

Is your feature request related to a problem?

Currently, import aliases are not resolved.

Desired solution

In two places in the code aliases have to be recognized and resolved:

  1. In the function safeds_stubgen.api_analyzer._mypy_helpers.mypy_type_to_abstract_type in the part
elif isinstance(mypy_type, mp_types.UnboundType):
    return sds_types.NamedType(name=mypy_type.name)
  1. In the function safeds_stubgen.api_analyzer._ast_visitor.MyPyAstVisitor.enter_classdef in the part
superclasses = [superclass.fullname for superclass in node.base_type_exprs if hasattr(superclass, "fullname")]

You should first look for a function in the mypy library that can resolve types. If such a function does not exist, you'd have to create one yourself. It's possible that such a function can already be found here: mypy.fixup.lookup_fully_qualified_alias

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    ✔️ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions