Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Resolve aliasing for imports #24

Closed
Masara opened this issue Oct 12, 2023 · 1 comment · Fixed by #50
Closed

feat: Resolve aliasing for imports #24

Masara opened this issue Oct 12, 2023 · 1 comment · Fixed by #50
Labels
enhancement 💡 New feature or request released Included in a release

Comments

@Masara
Copy link
Contributor

Masara commented Oct 12, 2023

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

@Masara Masara added the enhancement 💡 New feature or request label Oct 12, 2023
@Masara Masara changed the title feat: Import Aliasing auflösen feat: Resolve aliasing for imports Oct 12, 2023
lars-reimann pushed a commit that referenced this issue Feb 25, 2024
Closes #38 
Closes #24 

### Summary of Changes
- Reworked the import generation for Stubs. Imports should now be
correctly generated. (#38)
- Aliases are collected with mypy and are now used to resolve alias
origins (#24)

#### Other changes
- Added a "// Todo" for the generated Stubs, if an internal class is
used as a type.
- Added "// Todo Safe-DS does not support set types" if a set object is
used.
- If booleans where used in Literal Types the first letter was
capitalized in stubs, which it should not be.
- Removed the "where" part and lower limits of the Stubs for constrains

---------

Co-authored-by: megalinter-bot <[email protected]>
lars-reimann pushed a commit that referenced this issue Mar 29, 2024
## [0.2.0](v0.1.0...v0.2.0) (2024-03-29)

### Features

* Added generation for Safe-DS stubs files ([#33](#33)) ([ab45b45](ab45b45))
* Correct stubs for TypeVars ([#67](#67)) ([df8c5c9](df8c5c9)), closes [#63](#63)
* Create stubs for public methods of inherited internal classes ([#69](#69)) ([71b38d7](71b38d7)), closes [#64](#64)
* Rework import generation for stubs. ([#50](#50)) ([216e179](216e179)), closes [#38](#38) [#24](#24) [#38](#38) [#24](#24)
* Safe-DS stubs also contain docstring information. ([#78](#78)) ([bdb43bd](bdb43bd))
* Stubs are created for referenced declarations in other packages ([#70](#70)) ([522f38d](522f38d)), closes [#66](#66)

### Bug Fixes

* Some packages couldn't be analyzed ([#51](#51)) ([fa3d020](fa3d020)), closes [#48](#48)
* Stub generation testing and fixing of miscellaneous bugs ([#76](#76)) ([97b0ab3](97b0ab3))
@lars-reimann
Copy link
Member

🎉 This issue has been resolved in version 0.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 💡 New feature or request released Included in a release
Projects
Status: ✔️ Done
Development

Successfully merging a pull request may close this issue.

2 participants