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: Add variance handling for the stubs generator. #35

Closed
Masara opened this issue Nov 14, 2023 · 3 comments
Closed

feat: Add variance handling for the stubs generator. #35

Masara opened this issue Nov 14, 2023 · 3 comments
Assignees
Labels
enhancement 💡 New feature or request

Comments

@Masara
Copy link
Contributor

Masara commented Nov 14, 2023

Is your feature request related to a problem?

Currently code with variances is not handled during the stubs generation. If possible, this feature should be added.

Desired solution

In Python variance is inferred, therefor, if possible with Mypy, it should be inferred and added to the stubs generator.

Additional Context (optional)

@Masara Masara added the enhancement 💡 New feature or request label Nov 14, 2023
@Masara
Copy link
Contributor Author

Masara commented Nov 20, 2023

@lars-reimann With issue #36 we are able to create stubs like these:

# Python Code
_T_co = TypeVar("_T_co", covariant=True, bound=str)
_T_con = TypeVar("_T_con", contravariant=True, bound=int)

class ClassA(Generic[_T_co, _T_con]):
        ...
// Safe-DS stubs
class ClassA<out TCo, in TCon> where {
    TCo sub String,
    TCon super Int
}

Therefore, this Issue is also already finished, right? Or am I mixing variance and constrains up?

Masara added a commit that referenced this issue Nov 20, 2023
@lars-reimann
Copy link
Member

lars-reimann commented Nov 21, 2023

You can naturally handle constraints and variance in one PR, but they are different concepts:

Variance:

  • Python covariance=True -> Safe-DS out
  • Python contravariance=True -> Safe-DS in
  • Python neither -> Safe-DS no modifier

Bounds/constraints:

  • Python bound=... -> Safe-DS where block with type parameter constraints

@Masara
Copy link
Contributor Author

Masara commented Nov 21, 2023

Since I handled both concepts already in issue #36 I will close this issue.

@Masara Masara closed this as completed Nov 21, 2023
@Masara Masara self-assigned this Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 💡 New feature or request
Projects
Status: ✔️ Done
Development

No branches or pull requests

2 participants