Skip to content

Remove rpy2 workaround in conftest.py#41761

Merged
vbraun merged 1 commit intosagemath:developfrom
orlitzky:no-rpy2-pytest-hack
Mar 22, 2026
Merged

Remove rpy2 workaround in conftest.py#41761
vbraun merged 1 commit intosagemath:developfrom
orlitzky:no-rpy2-pytest-hack

Conversation

@orlitzky
Copy link
Copy Markdown
Contributor

@orlitzky orlitzky commented Mar 5, 2026

We currently have a hack in conftest.py for (the possibly absent) rpy2 in src/sage/interfaces/r.py, but apparently everything is fine without it.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 5, 2026

Documentation preview for this PR (built with commit 79960ad; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@orlitzky orlitzky requested a review from tobiasdiez March 5, 2026 20:22
@tobiasdiez
Copy link
Copy Markdown
Contributor

I'm a bit confused about how this is working for you as pytest is not able to understand the #needs annotations, neither global, block nor line comments. I also would be hesitant to add that feature to pytest.

The "this is a hack" comment mostly referred to that the file using rpy2 should throw a FeatureNotFound error if rpy2 is not available (instead of a ModuleNotFoundError), in which case the file then automatically gets ignored by

sage/conftest.py

Lines 149 to 152 in e37154c

except FeatureNotPresentError as exception:
pytest.skip(
f"unable to import module {self.path} due to missing feature {exception.feature.name}"
)

The import of rpy2 is lazy in src/sage/interfaces/r.py and the file is
skipped due to a FeatureNotPresentError.
@orlitzky
Copy link
Copy Markdown
Contributor Author

orlitzky commented Mar 6, 2026

Well TBH I assumed that it was not working, and that since it works now, I fixed it. But it was working to begin with!

@orlitzky orlitzky force-pushed the no-rpy2-pytest-hack branch from 0020c55 to 79960ad Compare March 6, 2026 12:36
@orlitzky
Copy link
Copy Markdown
Contributor Author

orlitzky commented Mar 6, 2026

Without changing anything in r.py:

=================================================================== short test summary info ===================================================================
SKIPPED [1] conftest.py:149: unable to import module /home/mjo/src/sage.git/src/sage/interfaces/r.py due to missing feature rpy2
===================================================================== 1 skipped in 0.54s =====================================================

@orlitzky orlitzky changed the title Add "needs rpy2" to sage.interfaces.r, and remove the pytest workaround in conftest.py Remove rpy2 workaround in conftest.py Mar 6, 2026
Copy link
Copy Markdown
Contributor

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's of course very nice ;-)

vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 15, 2026
sagemathgh-41761: Remove rpy2 workaround in conftest.py
    
We currently have a hack in conftest.py for (the possibly absent) rpy2
in `src/sage/interfaces/r.py`, but apparently everything is fine without
it.
    
URL: sagemath#41761
Reported by: Michael Orlitzky
Reviewer(s): Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 18, 2026
sagemathgh-41761: Remove rpy2 workaround in conftest.py
    
We currently have a hack in conftest.py for (the possibly absent) rpy2
in `src/sage/interfaces/r.py`, but apparently everything is fine without
it.
    
URL: sagemath#41761
Reported by: Michael Orlitzky
Reviewer(s): Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 21, 2026
sagemathgh-41761: Remove rpy2 workaround in conftest.py
    
We currently have a hack in conftest.py for (the possibly absent) rpy2
in `src/sage/interfaces/r.py`, but apparently everything is fine without
it.
    
URL: sagemath#41761
Reported by: Michael Orlitzky
Reviewer(s): Tobias Diez
@vbraun vbraun merged commit 4aa1ec1 into sagemath:develop Mar 22, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants