You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def assert_cannot_add(left, right, msg="cannot add"):
"""
Helper to assert that left and right cannot be added.
Parameters
----------
left : object
right : object
msg : str, default "cannot add"
"""
with pytest.raises(TypeError, match=msg):
left + right
with pytest.raises(TypeError, match=msg):
right + left
def assert_invalid_addsub_type(left, right, msg=None):
"""
Helper to assert that left and right can be neither added nor subtracted.
Parameters
----------
left : object
right : object
msg : str or None, default None
"""
with pytest.raises(TypeError, match=msg):
left + right
with pytest.raises(TypeError, match=msg):
right + left
with pytest.raises(TypeError, match=msg):
left - right
with pytest.raises(TypeError, match=msg):
right - left
Suggested fix for documentation
Enhance the docstrings to provide more detailed explanations for the functions and their parameters.
def assert_cannot_add(left, right, msg="cannot add"):
"""
Helper function to assert that two objects cannot be added.
Parameters
----------
left : object
The first operand.
right : object
The second operand.
msg : str, default "cannot add"
The error message expected in the TypeError.
"""
with pytest.raises(TypeError, match=msg):
left + right
with pytest.raises(TypeError, match=msg):
right + left
Ensure function names are consistent and descriptive.
def assert_invalid_add_subtraction(left, right, msg=None):
"""
Helper function to assert that two objects can neither be added nor subtracted.
Parameters
----------
left : object
The first operand.
right : object
The second operand.
msg : str or None, default None
The error message expected in the TypeError.
"""
with pytest.raises(TypeError, match=msg):
left + right
with pytest.raises(TypeError, match=msg):
right + left
with pytest.raises(TypeError, match=msg):
left - right
with pytest.raises(TypeError, match=msg):
right - left
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion!
The current name for the second function is still descriptive in my opinion and so I am against that change, changing function names should not be done lightly.
But the parameter descriptions seem helpful, PRs are welcome to add them!
Pandas version checks
main
hereLocation of the documentation
https://github.com/pandas-dev/pandas/blob/main/pandas/tests/arithmetic/common.py
Documentation problem
def assert_cannot_add(left, right, msg="cannot add"):
"""
Helper to assert that left and right cannot be added.
def assert_invalid_addsub_type(left, right, msg=None):
"""
Helper to assert that left and right can be neither added nor subtracted.
Suggested fix for documentation
Enhance the docstrings to provide more detailed explanations for the functions and their parameters.
def assert_cannot_add(left, right, msg="cannot add"):
"""
Helper function to assert that two objects cannot be added.
Ensure function names are consistent and descriptive.
def assert_invalid_add_subtraction(left, right, msg=None):
"""
Helper function to assert that two objects can neither be added nor subtracted.
The text was updated successfully, but these errors were encountered: