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: Analyzing TypeVar Variables and their usage and generating correct stubs #63

Closed
Masara opened this issue Feb 19, 2024 · 2 comments · Fixed by #67
Closed

feat: Analyzing TypeVar Variables and their usage and generating correct stubs #63

Masara opened this issue Feb 19, 2024 · 2 comments · Fixed by #67
Assignees
Labels
enhancement 💡 New feature or request released Included in a release

Comments

@Masara
Copy link
Contributor

Masara commented Feb 19, 2024

Is your feature request related to a problem?

Currently TypeVars are generated wrongly in the stubs.

Desired solution

The following TypeVar usages should generate correct stubs:

from typing import TypeVar

# Example 1
first_type_var = TypeVar("first_type_var")
def func(a: List[first_type_var]) -> first_type_var: ...

# Example 2
def  func2[T](a: T, b: T) -> T: ...

The stubs should look like the following:

# Example 1
@Pure
fun func<FirstTypeVar>(a: List<FirstTypeVar>) -> result1: FirstTypeVar

# Exmaple 2
@Pure
fun func2<T>(a: T) -> result1: T

To achieve this, while analyzing the code, perhaps a list of all TypeVars with their usages should be created.

@Masara Masara added the enhancement 💡 New feature or request label Feb 19, 2024
@lars-reimann
Copy link
Member

lars-reimann commented Feb 19, 2024

The stubs should look like the following:

# Example 1
@PythonName("first_type_var")
FirstTypeVar = "_type_var"

@Pure
fun func<FirstTypeVar>(a: List<FirstTypeVar>) -> result1: FirstTypeVar

# Exmaple 2
fun func2<T>(a: T) -> result1: T

The code is wrong and should not contain the first two lines:

// Example 1
@Pure
fun func<FirstTypeVar>(a: List<FirstTypeVar>) -> result1: FirstTypeVar

// Example 2
fun func2<T>(a: T) -> result1: T

See also this comment.

@Masara Masara self-assigned this Feb 25, 2024
@Masara Masara linked a pull request Feb 25, 2024 that will close this issue
lars-reimann pushed a commit that referenced this issue Feb 29, 2024
Closes #63

### Summary of Changes
TypeVars create correct stubs.

---------

Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
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