-
Notifications
You must be signed in to change notification settings - Fork 0
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: Rework import generation for stubs. #50
Conversation
… data for codecov; Refactoring
…and attribute types
…tor part; Refactoring
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #50 +/- ##
==========================================
+ Coverage 98.26% 98.76% +0.49%
==========================================
Files 25 25
Lines 1905 2017 +112
==========================================
+ Hits 1872 1992 +120
+ Misses 33 25 -8 ☔ View full report in Codecov by Sentry. |
🦙 MegaLinter status: ✅ SUCCESS
See detailed report in MegaLinter reports |
…es' into ignore_types_from_outside_packages
…es' into ignore_types_from_outside_packages
…es' into rework_import_generation
…types and result types
I'm done with this PR now, too @lars-reimann. Could you check this? |
Yes, probably tomorrow. Could you add a summary of changes? |
We also need a |
# Conflicts: # tests/conftest.py # tests/safeds_stubgen/stubs_generator/__snapshots__/test_generate_stubs.ambr # tests/safeds_stubgen/stubs_generator/test_generate_stubs.py
…s, which are not supported and adjusted snapshot test files
…ot be seen as strings if the parameter has a type hint of another type than string
@lars-reimann I fixed how the import paths are generated for stubs, now it should be correct. There was just one case where I wasn't sure how to handle it: If we have an import from another package, how should it look like? @PythonModule("various_modules_package.function_module")
package variousModulesPackage.functionModule
from tests.data.main_package.another_path.another_module import AnotherClass or this @PythonModule("various_modules_package.function_module")
package variousModulesPackage.functionModule
from mainPackage.AnotherPath.AnotherModule import AnotherClass ? Currently the first case is implemented. If it's correct like this, you can review and hopefully close this PR. |
The second option is correct, assuming the file containing
The part between |
@lars-reimann But we are assuming that we did not create the "mainPackage" Stubs yet and don't know where the mainPackage files are. What I concretely mean is, how do imports look like, if we import classes from other packages? Packages we perhaps did not create stubs for? The problem here is that we don't know how the package is named, like in the |
Say we are creating stubs for the package from b import SomeClass
def f(p: SomeClass) Then we also need to create some stub for the class For this PR it's sufficient to completely remove such imports, but please create an issue that stubs must be created for referenced declarations in other packages. |
@lars-reimann If I remove those imports for this PR, what about the types that use the imported classes? Should I removed them, too, for the time being? |
No, keep the types. |
…es' into rework_import_generation
@lars-reimann I removed the imports and created issue #66. You can proceed with the PR review. |
## [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))
🎉 This PR is included in version 0.2.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Closes #38
Closes #24
Summary of Changes
Other changes