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

Use result names in docstrings for result names in generated stubs #100

Closed
lars-reimann opened this issue Apr 4, 2024 · 6 comments · Fixed by #101 or #131
Closed

Use result names in docstrings for result names in generated stubs #100

lars-reimann opened this issue Apr 4, 2024 · 6 comments · Fixed by #101 or #131
Assignees
Labels
enhancement 💡 New feature or request released Included in a release

Comments

@lars-reimann
Copy link
Member

Is your feature request related to a problem?

Results currently always have names result1, result2, etc. Frequently, however, the docstrings contain proper names for the results.

Desired solution

Use result names in docstrings for result names in generated stubs.

Possible alternatives (optional)

No response

Screenshots (optional)

No response

Additional Context (optional)

No response

@lars-reimann lars-reimann added the enhancement 💡 New feature or request label Apr 4, 2024
@Masara Masara linked a pull request Apr 7, 2024 that will close this issue
@Masara Masara moved this from Backlog to Ready for Review in Library Analysis Apr 10, 2024
lars-reimann pushed a commit that referenced this issue Apr 11, 2024
Closes #100

### Summary of Changes

Result names for stubs from Numpy docstring are now supported. Google
and ReST don't support multiple results or named results, therefore they
handle these a bit different:
* For Google docstrings, if there are multiple results we only get the
first result docstring (type & description).
* For ReST we get all types, but only the last result description in the
docstring.

---------

Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from Ready for Review to ✔️ Done in Library Analysis Apr 11, 2024
@lars-reimann lars-reimann reopened this Apr 17, 2024
@github-project-automation github-project-automation bot moved this from ✔️ Done to Backlog in Library Analysis Apr 17, 2024
@lars-reimann
Copy link
Member Author

lars-reimann commented Apr 17, 2024

@Masara Reopening this, since the fix sometimes does not work:

  1. Generate stubs for the library.
  2. Check e.g. out\safeds\ml\classical\regression\_linear_regression\_linear_regression.sdsstub:
    /**
     * Create a copy of this regressor and fit it with the given training data.
     *
     * This regressor is not modified.
     *
     * @param trainingSet The training data containing the feature and target vectors.
     *
     * @result fittedRegressor The fitted regressor.
     */
    @Pure
    fun fit(
        @PythonName("training_set") trainingSet: TaggedTable
    ) -> result1: LinearRegressionRegressor

The result name in the docstring is correct, but the result is still called result1.

@Masara
Copy link
Contributor

Masara commented Apr 20, 2024

@lars-reimann should now be fixed with PR #108

@Masara Masara moved this from Backlog to Ready for Review in Library Analysis Apr 22, 2024
@lars-reimann
Copy link
Member Author

@lars-reimann should now be fixed with PR #108

Works again now, thanks.

@github-project-automation github-project-automation bot moved this from Ready for Review to ✔️ Done in Library Analysis Apr 25, 2024
@lars-reimann lars-reimann reopened this May 4, 2024
@github-project-automation github-project-automation bot moved this from ✔️ Done to Backlog in Library Analysis May 4, 2024
@lars-reimann
Copy link
Member Author

There are still some instances where the result is called result1 even though there's a name in the docstring. Generate stubs for Safe-DS/Library@46f54af and search globally for result1. Examples:

  • LogisticRegressionRegressor.predict
  • AdaBoostRegressor.predict
  • LabelEncoder.transform
  • LabelEncoder.reverseTransform

Maybe it's broken for overriding methods?

@Masara
Copy link
Contributor

Masara commented May 4, 2024

I'll fix this once #112 is merged.

lars-reimann pushed a commit that referenced this issue May 4, 2024
Closes #100

### Summary of Changes
Fixed a bug where results in stubs would not be named if the docstrings
did not specify a result type. Now results named if the

---------

Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from Backlog to ✔️ Done in Library Analysis May 4, 2024
lars-reimann pushed a commit that referenced this issue May 4, 2024
## [0.3.0](v0.2.0...v0.3.0) (2024-05-04)

### Features

* Added handling for sequence classes ([#127](#127)) ([cb061ab](cb061ab)), closes [#126](#126)
* DocString result names for Safe-DS stub results ([#101](#101)) ([fe163e3](fe163e3)), closes [#100](#100)
* Examples from docstrings are also taken over to stub docstrings ([#116](#116)) ([6665186](6665186)), closes [#115](#115)
* Replace the docstring_parser library with Griffe ([#79](#79)) ([9b2f802](9b2f802))

### Bug Fixes

* `Self` types as results are translated to class names  ([#110](#110)) ([4554a56](4554a56)), closes [#86](#86)
* Creating stubs with relative paths for source and output directories ([#128](#128)) ([b4493c9](b4493c9)), closes [#125](#125)
* Docstrings have the correct indentation for nested classes (stubs) ([#114](#114)) ([c7b8550](c7b8550)), closes [#113](#113)
* Fixed a bug where double ? would be generated for stubs ([#103](#103)) ([c35c6ac](c35c6ac)), closes [#87](#87) [#87](#87)
* Fixed a bug where imports would not check reexports for shortest path ([#112](#112)) ([48c5367](48c5367)), closes [#82](#82)
* Fixed a bug where results in stubs would not be named ([#131](#131)) ([4408c84](4408c84)), closes [#100](#100)
* Fixed a bug which prevented mypy version update ([#107](#107)) ([501d2cd](501d2cd))
* Fixed the stubs generator ([#108](#108)) ([9ad6df6](9ad6df6)), closes [#80](#80)
* Generated names of callback results start with result, not with param ([#104](#104)) ([6e696e9](6e696e9)), closes [#85](#85)
* Include lines of examples that start with `...` ([#130](#130)) ([3477b4a](3477b4a)), closes [#129](#129)
* No "// TODO ..." if return type is explicitly `None` ([#111](#111)) ([08e345f](08e345f)), closes [#83](#83)
* Removed the Epydoc parser ([#89](#89)) ([684a101](684a101))
* Replaced tabs with 4 spaces ([#105](#105)) ([8e7aa5d](8e7aa5d)), closes [#84](#84)
* The file structure of stubs resembles the "package" path. ([#106](#106)) ([ff1800e](ff1800e)), closes [#81](#81)
* Translation of callable ([#102](#102)) ([c581e6a](c581e6a)), closes [#88](#88) [#88](#88)
@lars-reimann
Copy link
Member Author

🎉 This issue has been resolved in version 0.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label May 4, 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
2 participants