Improve sage_getfile by looking at __init__#39499
Merged
vbraun merged 2 commits intosagemath:developfrom Feb 21, 2025
Merged
Conversation
3 tasks
|
Documentation preview for this PR (built with commit 6aee498; changes) is ready! 🎉 |
Contributor
|
You could use |
Contributor
Author
|
I copy the general structure from sage_getsourcelines . Presumably so that the attribute access only need to be done once ( Advantage is it would be 4 lines shorter I suppose. |
Contributor
|
Thanks. For me it's just much easier to read when the logic is "if thing is true, do stuff that depends on thing." |
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Feb 18, 2025
sagemathgh-39499: Improve sage_getfile by looking at __init__ Otherwise it will fail with meson editable install on objects like `x` of type `Expression`, where the class does not have a docstring but `__init__` method have. The strategy is similar to `sage_getsourcelines` where `__init__` method is looked in. I choose to implement this instead of the more complex workaround (see the comment below). This fixes the test that fails in meson editable mode: ``` 2025-02-11T20:13:36.4801998Z ********************************************************************** 2025-02-11T20:13:36.4803076Z File "src/sage/misc/sageinspect.py", line 1363, in sage.misc.sageinspect.sage_getfile_relative 2025-02-11T20:13:36.4804104Z Failed example: 2025-02-11T20:13:36.4804750Z sage_getfile_relative(x) # needs sage.symbolic 2025-02-11T20:13:36.4808395Z Expected: 2025-02-11T20:13:36.4813350Z 'sage/symbolic/expression.pyx' 2025-02-11T20:13:36.4814244Z Got: 2025-02-11T20:13:36.4815714Z '/home/runner/work/sage/sage/builddir/src/sage/symbolic/expression.pyx' 2025-02-11T20:13:44.3128543Z ********************************************************************** ``` This may still fail in another case where neither class nor `__init__` method has a docstring (in that case `?` will fail to get the file in meson editable mode), but that's not in scope I guess. (I left a comment there to explain) See also sagemath#39369 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. (change should be invisible to users not using meson editable so…) ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39499 Reported by: user202729 Reviewer(s):
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Mar 9, 2025
sagemathgh-39369: Test pip editable install with meson Tests pip editable install with meson on GitHub Actions. This uncovers several failing tests, which are fixed by (see dependencies below) Note: review is hard because of the large number of dependencies. It is probably easier to look only in `.github` folder. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. ### ⌛ Dependencies - sagemath#39423 - sagemath#39498 - sagemath#39494 - sagemath#39424 - sagemath#39275 - sagemath#39499 URL: sagemath#39369 Reported by: user202729 Reviewer(s): Tobias Diez, user202729
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Otherwise it will fail with meson editable install on objects like
xof typeExpression, where the class does not have a docstring but__init__method have.The strategy is similar to
sage_getsourcelineswhere__init__method is looked in.I choose to implement this instead of the more complex workaround (see the comment below).
This fixes the test that fails in meson editable mode:
This may still fail in another case where neither class nor
__init__method has a docstring (in that case?will fail to get the file in meson editable mode), but that's not in scope I guess. (I left a comment there to explain)See also #39369
📝 Checklist
⌛ Dependencies